Skip to content

Commit

Permalink
bugfix: fix read/write goroutine alive after tests
Browse files Browse the repository at this point in the history
TestConn_ReadWrite causes endless read/write in goroutines after
execution of the test. The patch fixes the problem.
  • Loading branch information
oleg-jukovec committed Jan 26, 2024
1 parent a2ad272 commit b6e0c4a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (m *mockIoConn) Read(b []byte) (int, error) {

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

if m.read != nil {
if ret != 0 && m.read != nil {
m.read <- struct{}{}
}

Expand Down Expand Up @@ -282,15 +282,17 @@ func TestConn_ReadWrite(t *testing.T) {
0x01, 0xce, 0x00, 0x00, 0x00, 0x02,
0x80, // Body map.
})
conn.Close()
})
defer func() {
dialer.conn.writeWg.Done()
conn.Close()
}()

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

<-dialer.conn.written
dialer.conn.written = nil

dialer.conn.readWg.Done()
<-dialer.conn.read
<-dialer.conn.read
Expand Down

0 comments on commit b6e0c4a

Please sign in to comment.