// Close closes the WriteOnCloser. It behaves like io.Closer.
977979
func (w *WriteOnCloser) Close() error {
	if !w.hasWritten {
		_, err := w.Write(nil)
		if err != nil {
			return err
		}
	}
	if closer, ok := w.Writer.(io.Closer); ok {
		return closer.Close()
	}
	return nil
}
435923
func (e *Engine) Close() error {
	e.mu.RLock()
	if e.closing == nil {
		return nil // Already closed
	}

	close(e.closing)
	e.mu.RUnlock()

	// Wait for any other goroutines to finish.
	e.wg.Wait()

	e.mu.Lock()
	defer e.mu.Unlock()
	e.closing = nil

	var ch closeHelper
	ch.Close(e.engine)
	ch.Close(e.wal)
	ch.Close(e.index)
	ch.Close(e.sfile)
	return ch.Done()
}
854460
func (c *CompressResponseWriter) Close() error {
	if c.closed {
		return nil
	}
	if !c.headersWritten {
		c.prepareHeaders()
	}
	if c.compressionType != "" {
		c.Header.Del("Content-Length")
		if err := c.compressWriter.Close(); err != nil {
			// TODO When writing directly to stream, an error will be generated
			compressLog.Error("Close: Error closing compress writer", "type", c.compressionType, "error", err)
		}

	}
	// Non-blocking write to the closenotifier, if we for some reason should
	// get called multiple times
	select {
	case c.closeNotify <- true:
	default:
	}
	c.closed = true
	return nil
}
290303
func (f *FileWriter) Close() error {
	f.mu.Lock()
	err := f.f.Close()
	f.mu.Unlock()
	return err
}
1192236
func (w *BatchedFileWriter) Close() error {
	if w.compressOnClose {
		return w.compressAndCloseLog()
	}

	return w.file.Close()
}
91426
func (writer *SocketWriter) Close() {
	writer.lock.Lock()
	defer writer.lock.Unlock()
	if writer.closed {
		return
	}

	writer.writer.Close()
	writer.writer = nil
	writer.closed = true
}
500604
func (w *BackupFileWriter) Close() error {
	if w.ctx != 0 {
		backupWrite(syscall.Handle(w.f.Fd()), nil, nil, true, false, &w.ctx)
		runtime.KeepAlive(w.f)
		w.ctx = 0
	}
	return nil
}
515229
func (w *DecryptBlocksWriter) Close() error {
	if w.decrypter != nil {
		err := w.decrypter.Close()
		if err != nil {
			return err
		}
	}

	if closer, ok := w.writer.(io.Closer); ok {
		return closer.Close()
	}
	return nil
}
522085
func (w *Writer) Close() error {
	if w.BeforeClose != nil {
		w.BeforeClose()
	}

	if closer, ok := w.Writer.(io.Closer); ok {
		err := closer.Close()
		if err != nil {
			return err
		}
	}

	if w.AfterClose != nil {
		w.AfterClose()
	}

	return nil
}
909574
func (w *Writer) Close() error {
	if w.mediaType != w.rootMediaType {
		return ErrTypeMatch
	}
	return w.w.Close()
}
431942
func (writer *ConsoleWriter) Close() {
	writer.lock.Lock()
	defer writer.lock.Unlock()

	if writer.closed {
		return
	}

	writer.blog.flush()
	writer.blog = nil
	writer.closed = true
}
1159648
func (dw *Writer) Close() (err error) {
	defer func() {
		if wc, ok := dw.Writer.(io.Closer); ok {
			cErr := wc.Close()
			if cErr != nil && err == nil {
				err = cErr
			}
		}
	}()

	if dw.offset > 0 {
		buf := dw.Buffer[:dw.offset]

		if dw.Validate != nil {
			err = dw.Validate(buf)
			if err != nil {
				return
			}
		}

		_, err = dw.Writer.Write(buf)
		if err != nil {
			return
		}
		dw.offset = 0
	}

	return
}
502737
func (rw rwCloser) Close() error {
	err := rw.ReadCloser.Close()
	if err := rw.WriteCloser.Close(); err != nil {
		return err
	}
	return err
}
229048
func (c *compressionResponseWriter) Close() error {
	if c.compressorClosed() {
		return errors.New("Compressing error: tried to close already closed compressor")
	}

	c.compressor.Close()
	c.compressor = nil
	return nil
}
830718
func (l *Log) close() {
	l.mutex.Lock()
	defer l.mutex.Unlock()

	if l.file != nil {
		l.file.Close()
		l.file = nil
	}
	l.entries = make([]*LogEntry, 0)
}
665972
func (w *minifyResponseWriter) Close() error {
	if w.writer != nil {
		return w.writer.Close()
	}
	return nil
}
1030937
func (w *WriteContext) Close() error {
	if c, ok := w.writer.(io.Closer); ok {
		err := c.Close()
		if err != nil {
			return errors.WithStack(err)
		}
	}

	return nil
}