mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-21 10:27:26 +08:00
Release buffers in edge cases (#374)
This commit is contained in:
parent
db66b3f118
commit
af0eded231
@ -77,6 +77,7 @@ func (p *PubSub) handleNewStream(s network.Stream) {
|
||||
return
|
||||
}
|
||||
if len(msgbytes) == 0 {
|
||||
r.ReleaseMsg(msgbytes)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -186,18 +187,18 @@ func (p *PubSub) handleSendingMessages(ctx context.Context, s network.Stream, ou
|
||||
s.Reset()
|
||||
log.Debugf("writing message to %s: %s", s.Conn().RemotePeer(), err)
|
||||
s.Close()
|
||||
pool.Put(buf)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = s.Write(buf)
|
||||
pool.Put(buf)
|
||||
if err != nil {
|
||||
s.Reset()
|
||||
log.Debugf("writing message to %s: %s", s.Conn().RemotePeer(), err)
|
||||
s.Close()
|
||||
return
|
||||
}
|
||||
|
||||
pool.Put(buf)
|
||||
case <-ctx.Done():
|
||||
s.Close()
|
||||
return
|
||||
|
||||
Loading…
Reference in New Issue
Block a user