Skip to content

Commit

Permalink
Don't release resources until all current requests are complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
howbazaar committed Nov 13, 2017
1 parent c8738ca commit b18626e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,18 @@ func (conn *Conn) Close() error {
return nil
}
conn.closing = true
if conn.root != nil {
conn.root.Kill()
}
conn.mutex.Unlock()

// Wait for any outstanding server requests to complete
// and write their replies before closing the codec.
conn.srvPending.Wait()

conn.mutex.Lock()
if conn.root != nil {
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)
Expand Down

0 comments on commit b18626e

Please sign in to comment.