summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/tcp/endpoint.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2019-07-23 19:19:17 +0000
committergVisor bot <gvisor-bot@google.com>2019-07-23 19:19:17 +0000
commit60c7874888b969bcb5a95d7e76804823e451e6ae (patch)
treefdb20b83f3dc2e9371bfdd0ac08cccc906c47cf9 /pkg/tcpip/transport/tcp/endpoint.go
parent9540b0be19d424e9a4e949176622ce68727502ff (diff)
parent12c256568ba784c07cf73822359faac2971e8306 (diff)
Merge 12c25656 (automated)
Diffstat (limited to 'pkg/tcpip/transport/tcp/endpoint.go')
-rw-r--r--pkg/tcpip/transport/tcp/endpoint.go24
1 files changed, 13 insertions, 11 deletions
diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go
index 89154391b..cc49c8272 100644
--- a/pkg/tcpip/transport/tcp/endpoint.go
+++ b/pkg/tcpip/transport/tcp/endpoint.go
@@ -489,8 +489,8 @@ func (e *endpoint) Readiness(mask waiter.EventMask) waiter.EventMask {
result |= waiter.EventIn
}
}
-
- case StateEstablished, StateFinWait1, StateFinWait2, StateTimeWait, StateCloseWait, StateLastAck, StateClosing:
+ }
+ if e.state.connected() {
// Determine if the endpoint is writable if requested.
if (mask & waiter.EventOut) != 0 {
e.sndBufMu.Lock()
@@ -1323,6 +1323,17 @@ func (e *endpoint) connect(addr tcpip.FullAddress, handshake bool, run bool) (er
return err
}
+ if e.state.connected() {
+ // The endpoint is already connected. If caller hasn't been
+ // notified yet, return success.
+ if !e.isConnectNotified {
+ e.isConnectNotified = true
+ return nil
+ }
+ // Otherwise return that it's already connected.
+ return tcpip.ErrAlreadyConnected
+ }
+
nicid := addr.NIC
switch e.state {
case StateBound:
@@ -1347,15 +1358,6 @@ func (e *endpoint) connect(addr tcpip.FullAddress, handshake bool, run bool) (er
// yet.
return tcpip.ErrAlreadyConnecting
- case StateEstablished:
- // The endpoint is already connected. If caller hasn't been notified yet, return success.
- if !e.isConnectNotified {
- e.isConnectNotified = true
- return nil
- }
- // Otherwise return that it's already connected.
- return tcpip.ErrAlreadyConnected
-
case StateError:
return e.hardError