Skip to content
This repository was archived by the owner on Apr 3, 2021. It is now read-only.

Commit 7ba5098

Browse files
author
ghost
committed
Handle connection state more carefully
1 parent e85c430 commit 7ba5098

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/tcp_conn.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ func newTCPConn(pcb *C.struct_tcp_pcb, handler TCPConnHandler) (TCPConn, error)
114114
conn.Abort()
115115
} else {
116116
conn.Lock()
117+
if conn.state != tcpConnecting {
118+
conn.Unlock()
119+
return
120+
}
117121
conn.state = tcpConnected
118122
conn.Unlock()
119123

@@ -158,11 +162,11 @@ func (conn *tcpConn) receiveCheck() error {
158162
case tcpNewConn:
159163
fallthrough
160164
case tcpConnecting:
161-
fallthrough
165+
return NewLWIPError(LWIP_ERR_CONN)
162166
case tcpAborting:
163167
fallthrough
164168
case tcpClosed:
165-
return NewLWIPError(LWIP_ERR_CONN)
169+
fallthrough
166170
case tcpReceiveClosed:
167171
fallthrough
168172
case tcpClosing:

0 commit comments

Comments
 (0)