// epollclose closes the file descriptor created by the call to epoll_create(2)
// and two file descriptors opened by pipe(2) function.
974228
func (i *inotify) epollclose() (err error) {
	if i.epfd != invalidDescriptor {
		if err = unix.Close(i.epfd); err == nil {
			i.epfd = invalidDescriptor
		}
	}
	for n, fd := range i.pipefd {
		if fd != invalidDescriptor {
			switch e := unix.Close(fd); {
			case e != nil && err == nil:
				err = e
			case e == nil:
				i.pipefd[n] = invalidDescriptor
			}
		}
	}
	return
}
758765
func (s *Session) OnClose(c func()) error {
	if !s.IsFrontend {
		return constants.ErrOnCloseBackend
	}
	s.OnCloseCallbacks = append(s.OnCloseCallbacks, c)
	return nil
}
600964
func (s *Snapshot) Close() error {
	if s == nil {
		return nil
	}

	if err := s.file.Close(); err != nil {
		return err
	}
	return os.Remove(s.file.Name())
}
1085521
func MultiWriteCloser(wc ...io.WriteCloser) io.WriteCloser {
	wcs := make([]io.WriteCloser, len(wc))
	copy(wcs, wc)
	return &mwc{wcs}
}
1049078
func drainAndClose(body io.ReadCloser) {
	io.CopyN(ioutil.Discard, body, 10*1024)
	body.Close()
}
1240794
func (s *safeCloser) Close() (err error) {
	if s.r != nil {
		err = s.r.Close()
	} else if s.w != nil {
		err = s.w.Close()
	}

	select {
	case s.ch <- struct{}{}:
		return err
	default:
		return s.c.Close()
	}
}
388233
func (e *Epoller) CloseConsole(fd int) error {
	e.mu.Lock()
	defer e.mu.Unlock()
	delete(e.fdMapping, fd)
	return unix.EpollCtl(e.efd, unix.EPOLL_CTL_DEL, fd, &unix.EpollEvent{})
}
833237
func (f *fragment) safeClose() error {
	// Flush file, unlock & close.
	if f.file != nil {
		if err := f.file.Sync(); err != nil {
			return fmt.Errorf("sync: %s", err)
		}
		if err := syscall.Flock(int(f.file.Fd()), syscall.LOCK_UN); err != nil {
			return fmt.Errorf("unlock: %s", err)
		}
		if err := syswrap.CloseFile(f.file); err != nil {
			return fmt.Errorf("close file: %s", err)
		}
	}
	f.file = nil
	f.storage.OpWriter = nil

	return nil
}
785717
func (ics *IterateCloserStruct) Close() error {
	if ics.CloserF != nil {
		return ics.CloserF()
	}
	return nil
}
82200
func (lw *LazyFile) Close() error {
	if lw.file != nil {
		return lw.file.Close()
	}
	return nil
}
1288632
func (f *SeriesFile) Close() (err error) {
	f.mu.Lock()
	defer f.mu.Unlock()

	// Close the resource and wait for any outstanding references.
	f.res.Close()

	for _, p := range f.partitions {
		if e := p.Close(); e != nil && err == nil {
			err = e
		}
	}

	return err
}
910016
func (iop ioPipe) Close() error {
	err := iop.ReadCloser.Close()
	if writeErr := iop.WriteCloser.Close(); writeErr != nil {
		err = writeErr
	}
	if procErr := iop.closeProc(); procErr != nil {
		err = procErr
	}
	return err
}
957525
func (writer *baseFileWriter) Close() {
	writer.lock.Lock()
	defer writer.lock.Unlock()

	if writer.closed {
		return
	}

	writer.closed = true
	writer.blog.flush()
	writer.blog.Close()
	writer.blog = nil
	writer.file.Close()
	close(writer.logSizeChan)
	close(writer.timeRotateSig)
	close(writer.sizeRotateSig)
}
380612
func (w *writeCloseInformer) Close() error {
	err := w.wc.Close()
	close(w.close)
	return err
}
1125406
func (file *File) Close() error {
	// Should we cancel all pending requests for the File
	return file.Fid.Clnt.Clunk(file.Fid)
}
1020428
func (p *Partition) close() error {
	// Release series file.
	if p.sfileref != nil {
		p.sfileref.Release()
		p.sfileref = nil
	}

	// Release the file set and close all of the files.
	var err error
	if p.fileSet != nil {
		p.fileSet.Release()
		for _, file := range p.fileSet.files {
			if e := file.Close(); e != nil && err == nil {
				err = e
			}
		}
		p.fileSet = nil
	}

	return err
}
872916
func (t *File) Close() error {
	if t.fh == nil {
		return nil
	}
	return t.fh.Close()
}