diff --git a/gnet.go b/gnet.go index 047b4ef98..fd3098913 100644 --- a/gnet.go +++ b/gnet.go @@ -226,6 +226,12 @@ type Writer interface { // AsyncWrite writes bytes to peer asynchronously, it's goroutine-safe, // you don't have to invoke it within any method in EventHandler, // usually you would call it in an individual goroutine. + // + // Note that it will go synchronously with UDP, so it is needless to call + // this asynchronous method, we may disable this method for UDP and just + // return ErrUnsupportedOp in the future, therefore, please don't rely on + // this method to do something important under UDP, if you're working with UDP, + // just call Conn.Write to send back your data. AsyncWrite(buf []byte, callback AsyncCallback) (err error) // AsyncWritev writes multiple byte slices to peer asynchronously, diff --git a/gnet_test.go b/gnet_test.go index abf5ee569..927dbad95 100644 --- a/gnet_test.go +++ b/gnet_test.go @@ -552,6 +552,11 @@ func (t *testWakeConnServer) OnTick() (delay time.Duration, action Action) { } func testWakeConn(t *testing.T, network, addr string) { + currentLogger, currentFlusher := logging.GetDefaultLogger(), logging.GetDefaultFlusher() + t.Cleanup(func() { + logging.SetDefaultLoggerAndFlusher(currentLogger, currentFlusher) // restore + }) + svr := &testWakeConnServer{tester: t, network: network, addr: addr, conn: make(chan Conn, 1)} logger := zap.NewExample() err := Run(svr, network+"://"+addr, @@ -1145,6 +1150,11 @@ func (t *testMultiInstLoggerRaceServer) OnBoot(_ Engine) (action Action) { } func TestMultiInstLoggerRace(t *testing.T) { + currentLogger, currentFlusher := logging.GetDefaultLogger(), logging.GetDefaultFlusher() + t.Cleanup(func() { + logging.SetDefaultLoggerAndFlusher(currentLogger, currentFlusher) // restore + }) + logger1, _ := zap.NewDevelopment() events1 := new(testMultiInstLoggerRaceServer) g := errgroup.Group{}