Skip to content

Commit f89201d

Browse files
committed
Critical bug fix: preventing getting stuck on select() forever at shutdown.
1 parent ad1799b commit f89201d

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

debian/changelog

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
loghogd (7) quantal; urgency=high
1+
loghogd (8) lucid; urgency=high
2+
3+
* Critical bug fix: preventing getting stuck on select() forever at
4+
shutdown.
5+
6+
-- Igor Partola <igor@activefrequency.com> Fri, 01 Feb 2013 16:32:18 -0500
7+
8+
loghogd (7) lucid; urgency=high
29

310
* Critical bug fix: buffer overfill caused exception in the server module.
411

loghogd/server.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def __init__(self, callback, conf_root, listen_ipv4=None, listen_ipv6=None, defa
7878

7979
self.client_socket_addrs = {}
8080

81+
self.select_timeout = None # Set on shutdown to prevent infinite wait
82+
8183
self.pemfile = normalize_path(pemfile if pemfile is not None else options.server.pemfile, conf_root)
8284
self.cacert = normalize_path(cacert if cacert is not None else options.server.cacert, conf_root)
8385

@@ -171,17 +173,16 @@ def run(self):
171173

172174
while True:
173175
try:
174-
r, w, e = select.select(self.all_socks, [], self.all_socks)
176+
if self.select_timeout:
177+
r, w, _ = select.select(self.all_socks, [], [], self.select_timeout)
178+
else:
179+
r, w, _ = select.select(self.all_socks, [], [])
175180
except Exception as exc:
176181
if isinstance(exc, select.error) and exc.args[0] == 4:
177182
continue # Got signal, probably HUP
178183
else:
179184
raise
180185

181-
for sock in e:
182-
# Disconnect error streams
183-
self.disconnect_client_stream(sock)
184-
185186
for sock in r:
186187
if sock in self.dgram_socks:
187188
# Receive datagram
@@ -298,15 +299,16 @@ def close(self):
298299
for sock in self.client_stream_socks:
299300
sock.shutdown(socket.SHUT_RDWR)
300301

301-
time.sleep(self.SHUTDOWN_TIMEOUT)
302+
if self.client_stream_socks:
303+
time.sleep(self.SHUTDOWN_TIMEOUT)
302304

303305
for sock in self.all_socks:
304306
sock.close()
305307

306-
307308
def shutdown(self):
308309
'''Notifies the server of a shutdown condition.'''
309310

310311
self.closed = True
312+
self.select_timeout = self.SHUTDOWN_TIMEOUT
311313

312314

loghogd/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
__version__ = '7'
2+
__version__ = '8'

0 commit comments

Comments
 (0)