Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-node
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-node
Commits
21235886
Commit
21235886
authored
13 years ago
by
Thibault VINCENT
Browse files
Options
Downloads
Patches
Plain Diff
add: tcptunnel better detection of disconnection
parent
9bcbc99b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ccnode/jobs.py
+13
-3
13 additions, 3 deletions
ccnode/jobs.py
with
13 additions
and
3 deletions
ccnode/jobs.py
+
13
−
3
View file @
21235886
...
...
@@ -981,7 +981,7 @@ class TCPTunnelJob(BaseJob):
except
socket
.
timeout
:
pass
if
self
.
_sock_server
is
None
:
re
turn
# job cancelled
b
re
ak
# job cancelled
## connect to the endpoint
timeout
=
15
# FIXME must be argument
...
...
@@ -1000,7 +1000,7 @@ class TCPTunnelJob(BaseJob):
self
.
_log
.
append
(
'
socket error (connection refused ?)
'
)
time
.
sleep
(
retry_interval
)
if
self
.
_cancelled
:
re
turn
b
re
ak
if
not
connected
:
continue
...
...
@@ -1014,11 +1014,11 @@ class TCPTunnelJob(BaseJob):
# forward data until a connection is closed
buf_server
=
''
buf_client
=
''
empty_buf
=
0
connected
=
True
while
not
self
.
_cancelled
and
connected
:
# wait for events on both sockets
poll
=
poller
.
poll
()
## process events for read/write operations only
for
fd
,
events
in
poll
:
# events are for server socket
if
fd
==
self
.
_sock_server
.
fileno
():
...
...
@@ -1029,6 +1029,10 @@ class TCPTunnelJob(BaseJob):
read
=
self
.
_sock_server
.
recv
(
4096
)
except
socket
.
error
:
connected
=
False
if
not
len
(
read
):
empty_buf
+=
1
else
:
empty_buf
=
0
buf_server
+=
read
# set the other socket to notify us when it's
# available for writing
...
...
@@ -1055,6 +1059,10 @@ class TCPTunnelJob(BaseJob):
read
=
self
.
_sock_client
.
recv
(
4096
)
except
socket
.
error
:
connected
=
False
if
not
len
(
read
):
empty_buf
+=
1
else
:
empty_buf
=
0
buf_client
+=
read
# set the other socket to notify us when it's
# available for writing
...
...
@@ -1072,6 +1080,8 @@ class TCPTunnelJob(BaseJob):
# if the buffer becomes empty, stop write polling
if
not
len
(
buf_server
):
poller
.
modify
(
self
.
_sock_client
,
mask_ro
)
if
empty_buf
>=
10
:
connected
=
False
if
connected
is
False
:
self
.
_log
.
append
(
'
disconnected
'
)
try
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment