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

Commit

Permalink
Handle connection state more carefully
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost committed Aug 9, 2020
1 parent e85c430 commit 7ba5098
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/tcp_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ func newTCPConn(pcb *C.struct_tcp_pcb, handler TCPConnHandler) (TCPConn, error)
conn.Abort()
} else {
conn.Lock()
if conn.state != tcpConnecting {
conn.Unlock()
return
}
conn.state = tcpConnected
conn.Unlock()

Expand Down Expand Up @@ -158,11 +162,11 @@ func (conn *tcpConn) receiveCheck() error {
case tcpNewConn:
fallthrough
case tcpConnecting:
fallthrough
return NewLWIPError(LWIP_ERR_CONN)
case tcpAborting:
fallthrough
case tcpClosed:
return NewLWIPError(LWIP_ERR_CONN)
fallthrough
case tcpReceiveClosed:
fallthrough
case tcpClosing:
Expand Down

0 comments on commit 7ba5098

Please sign in to comment.