diff options
-rw-r--r-- | xgob.go | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -264,17 +264,16 @@ func (c *Connection) fullSeq(seq uint16) uint64 { func (c *Connection) registerReply (reply chan interface{}) { c.replyMutex.Lock() - defer c.replyMutex.Unlock() c.lastRequestWritten++ if reply != nil { c.reply[c.lastRequestWritten] = reply } + c.replyMutex.Unlock() } func (c *Connection) postReply (seq uint64, reply interface{}) { c.replyMutex.Lock() - defer c.replyMutex.Unlock() if seq != c.lastSequenceRead { c.reply[c.lastSequenceRead] = nil, false @@ -297,6 +296,8 @@ func (c *Connection) postReply (seq uint64, reply interface{}) { } } c.lastSequenceRead = seq + + c.replyMutex.Unlock() } func (c *Connection) read (in *bufio.Reader) { @@ -377,7 +378,6 @@ func (c *Connection) Disconnect () { func (c *Connection) writeRequest (req []byte, replier bool, rv chan interface{}) { c.writeMutex.Lock() - defer c.writeMutex.Unlock() c.registerReply(rv) c.out.Write(req) @@ -391,6 +391,7 @@ func (c *Connection) writeRequest (req []byte, replier bool, rv chan interface{} c.lastReplierSent = c.lastRequestWritten } } + c.writeMutex.Unlock() } func (c *Connection) WriteMultiRequest (req []byte, expected int) chan interface{} { @@ -429,9 +430,8 @@ func (c *Connection) Flush () { } c.writeMutex.Lock() - defer c.writeMutex.Unlock() - c.out.Flush() + c.writeMutex.Unlock() } func (c *Connection) HasError () bool { |