commit bbda90f30ff3cdc0e00695a0b925c5833206bc13
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Thu Feb 6 13:39:11 2014 +0100
ConnectionHandler: retrieve ALL messages from connections
The check_connections method only recieved one message per file
descriptor. This wasn't a problem because the other messages would be
retrieved in the next iteration. However this way we will be able to
order the recieved messages, so that messages from the controller can be
handled last, after all recieved updates (e.g. netlink).
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/ConnectionHandler.py | 39 ++++++++++++++++++++++++-------------
1 files changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/lnst/Common/ConnectionHandler.py b/lnst/Common/ConnectionHandler.py
index c0a43fa..04eef86 100644
--- a/lnst/Common/ConnectionHandler.py
+++ b/lnst/Common/ConnectionHandler.py
@@ -76,22 +76,33 @@ class ConnectionHandler(object):
except select.error:
return []
for f in rl:
- try:
- data = recv_data(f)
-
- if data == "":
+ f_ready = True
+ while f_ready:
+ try:
+ data = recv_data(f)
+
+ if data == "":
+ f.close()
+ self.remove_connection(f)
+ f_ready = False
+ else:
+ id = self.get_connection_id(f)
+ requests.append((id, data))
+
+ #poll the file descriptor if there is another message
+ rll, _, _ = select.select([f], [], [], 0)
+ if rll == []:
+ f_ready = False
+
+ except socket.error:
+ f_ready = False
+ f.close()
+ self.remove_connection(f)
+ except EOFError:
+ f_ready = False
f.close()
self.remove_connection(f)
- else:
- id = self.get_connection_id(f)
- requests.append((id, data))
-
- except socket.error:
- f.close()
- self.remove_connection(f)
- except EOFError:
- f.close()
- self.remove_connection(f)
+
return requests
def get_connection(self, id):
Show replies by date