1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-02-20 23:47:21 -05:00

yield goroutine on pipe write

This commit is contained in:
Darien Raymond 2018-11-11 18:58:58 +01:00
parent 3f3d00298a
commit 956868ef78
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -3,6 +3,7 @@ package pipe
import ( import (
"errors" "errors"
"io" "io"
"runtime"
"sync" "sync"
"time" "time"
@ -125,6 +126,9 @@ func (p *pipe) WriteMultiBuffer(mb buf.MultiBuffer) error {
switch { switch {
case err == nil: case err == nil:
p.readSignal.Signal() p.readSignal.Signal()
// Yield current goroutine. Hopefully the reading counterpart can pick up the payload.
runtime.Gosched()
return nil return nil
case err == errBufferFull && p.discardOverflow: case err == errBufferFull && p.discardOverflow:
mb.Release() mb.Release()