Skip to content

Commit b6e0c4a

Browse files
committed
bugfix: fix read/write goroutine alive after tests
TestConn_ReadWrite causes endless read/write in goroutines after execution of the test. The patch fixes the problem.
1 parent a2ad272 commit b6e0c4a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dial_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (m *mockIoConn) Read(b []byte) (int, error) {
107107

108108
ret, err := m.readbuf.Read(b)
109109

110-
if m.read != nil {
110+
if ret != 0 && m.read != nil {
111111
m.read <- struct{}{}
112112
}
113113

@@ -282,15 +282,17 @@ func TestConn_ReadWrite(t *testing.T) {
282282
0x01, 0xce, 0x00, 0x00, 0x00, 0x02,
283283
0x80, // Body map.
284284
})
285-
conn.Close()
286285
})
287286
defer func() {
288287
dialer.conn.writeWg.Done()
288+
conn.Close()
289289
}()
290290

291291
fut := conn.Do(tarantool.NewPingRequest())
292292

293293
<-dialer.conn.written
294+
dialer.conn.written = nil
295+
294296
dialer.conn.readWg.Done()
295297
<-dialer.conn.read
296298
<-dialer.conn.read

0 commit comments

Comments
 (0)