Module: check_mk
Branch: master
Commit: fd3603e0cd0db2cd798cef0b19addbe1ba5be686
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fd3603e0cd0db2…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Aug 20 16:16:31 2013 +0200
mknotifyd: fixed recv() of notification messages in multiple chunks
---
doc/treasures/mknotifyd | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/doc/treasures/mknotifyd b/doc/treasures/mknotifyd
index 042cce2..f5be9f4 100755
--- a/doc/treasures/mknotifyd
+++ b/doc/treasures/mknotifyd
@@ -232,10 +232,25 @@ class TcpServer:
while not self._should_terminate:
readable = select.select([self._tcp_socket], [], [], 0.5)[0]
for s in readable:
+ client_data = ""
+ chunk_count = 0
client_socket, addr_info = s.accept()
- client_data = client_socket.recv(8192)
+ while True:
+ try:
+ data_ready = select.select([client_socket], [], [], 2)[0]
+ if data_ready:
+ chunk = client_socket.recv(8192)
+ if not chunk:
+ break
+ chunk_count += 1
+ client_data += chunk
+ else:
+ break
+ except:
+ break # Error while reading
+
if opt_verbose > 1:
- verbose("Received notification %d from %s" % (
handled_connections, pprint.pformat(addr_info)), 2)
+ verbose("Received notification %d from %s in %d chunks" % (
handled_connections, pprint.pformat(addr_info), chunk_count), 2)
handled_connections = handled_connections + 1
try: