mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-30 13:35:19 +00:00
recover if we try to send to a closed session worker due to a race between a Conn.Write call and a Conn.Close call
This commit is contained in:
parent
28db566b37
commit
d39428735d
@ -236,6 +236,11 @@ func (c *Conn) Write(b []byte) (bytesWritten int, err error) {
|
||||
timer := getDeadlineTimer(&c.writeDeadline)
|
||||
defer util.TimerStop(timer)
|
||||
// Hand over to the session worker
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
err = errors.New("write failed")
|
||||
}
|
||||
}() // In case we're racing with a close
|
||||
select { // Send to worker
|
||||
case sinfo.worker <- workerFunc:
|
||||
case <-timer.C:
|
||||
|
Loading…
Reference in New Issue
Block a user