func (conn *Conn) Close() error {
	conn.mutex.Lock()
	if conn.closing {
		conn.mutex.Unlock()
		// Golang's net/rpc returns rpc.ErrShutdown if you ask to close
		// a closing or shutdown connection. Our choice is that Close
		// is an idempotent way to ask for resources to be released and
		// isn't a failure if called multiple times.
		return nil
	}
	conn.closing = true
	if conn.root != nil {
		// Kill calls down into the resources to stop all the resources which
		// includes watchers. The watches need to be killed in order for their
		// API methods to return, otherwise they are just waiting.
		conn.root.Kill()
	}
	conn.mutex.Unlock()

	// Wait for any outstanding server requests to complete
	// and write their replies before closing the codec. We
	// cancel the context so that any requests that would
	// block will be notified that the server is shutting
	// down.
	conn.cancelContext()
	conn.srvPending.Wait()

	conn.mutex.Lock()
	if conn.root != nil {
		// It is possible that since we last Killed the root, other resources
		// may have been added during some of the pending call resolutions.
		// So to release these resources, double tap the root.
		conn.root.Kill()
	}
	conn.mutex.Unlock()

	// Closing the codec should cause the input loop to terminate.
	if err := conn.codec.Close(); err != nil {
		logger.Debugf("error closing codec: %v", err)
	}
	<-conn.dead

	return conn.inputLoopError
}
// Close closes the connection and its underlying codec; it returns when
// all requests have been terminated.
//
// If the connection is serving requests, and the root value implements
// the Killer interface, its Kill method will be called.  The codec will
// then be closed only when all its outstanding server calls have
// completed.
//
// Calling Close multiple times is not an error.
Close closes the connection and its underlying codec; it returns when
all requests have been terminated.

If the connection is serving requests, and the root value implements
the Killer interface, its Kill method will be called.  The codec will
then be closed only when all its outstanding server calls have
completed.

Calling Close multiple times is not an error.
// Close closes the connection and its underlying codec ; it returns when // all requests have been terminated . // // If the connection is serving requests and the root value implements // the Killer interface its Kill method will be called . The codec will // then be closed only when all its outstanding server calls have // completed . // // Calling Close multiple times is not an error .
func (conn *Conn) Close() error {
	conn.mutex.Lock()
	if conn.closing {
		conn.mutex.Unlock()
		return nil
	}
	conn.closing = true
	if conn.root != nil {
		conn.root.Kill()
	}
	conn.mutex.Unlock()
	conn.cancelContext()
	conn.srvPending.Wait()
	conn.mutex.Lock()
	if conn.root != nil {
		conn.root.Kill()
	}
	conn.mutex.Unlock()
	if err := conn.codec.Close(); err != nil {
		logger.Debugf("error closing codec: %v", err)
	}
	<-conn.dead
	return conn.inputLoopError
}
func ( conn * Conn ) Close ( ) error { conn . mutex . Lock ( ) if conn . closing { conn . mutex . Unlock ( ) return nil } conn . closing = true if conn . root != nil { conn . root . Kill ( ) } conn . mutex . Unlock ( ) conn . cancelContext ( ) conn . srvPending . Wait ( ) conn . mutex . Lock ( ) if conn . root != nil { conn . root . Kill ( ) } conn . mutex . Unlock ( ) if err := conn . codec . Close ( ) ; err != nil { logger . Debugf ( " " , err ) } <- conn . dead return conn . inputLoopError }
Close closes the connection and its underlying codec; it returns when
all requests have been terminated.
Close closes the connection and its underlying codec ; it returns when all requests have been terminated .
// Golang's net/rpc returns rpc.ErrShutdown if you ask to close // a closing or shutdown connection. Our choice is that Close // is an idempotent way to ask for resources to be released and // isn't a failure if called multiple times. // Kill calls down into the resources to stop all the resources which // includes watchers. The watches need to be killed in order for their // API methods to return, otherwise they are just waiting. // Wait for any outstanding server requests to complete // and write their replies before closing the codec. We // cancel the context so that any requests that would // block will be notified that the server is shutting // down. // It is possible that since we last Killed the root, other resources // may have been added during some of the pending call resolutions. // So to release these resources, double tap the root. // Closing the codec should cause the input loop to terminate.