[Kimchi-devel] [PATCH] [WoK] Bug fix #217: Fixing select() waking up

dhbarboza82@gmail.com posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/kimchi-wok tags/patchew/20170503122907.4699-1-dhbarboza82@gmail.com
src/wok/pushserver.py | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
[Kimchi-devel] [PATCH] [WoK] Bug fix #217: Fixing select() waking up
Posted by dhbarboza82@gmail.com 6 years, 11 months ago
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>

There was a condition in the close of the Websocket that wasn't
being covered properly by the pushserver prior to this patch. The
fix was to put an additional condition to close our remote socket
reference when we receive no data from it, instead of relying just
in the Except call to do it.

While we're at it, a cleanup was made in the code to remove a
condition of a 'CLOSE' message that was being sent in the first
versions of the Pushserver but didn't make upstream.

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
---
 src/wok/pushserver.py | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/wok/pushserver.py b/src/wok/pushserver.py
index 6cad2cf..8b16f3d 100644
--- a/src/wok/pushserver.py
+++ b/src/wok/pushserver.py
@@ -108,31 +108,27 @@ class PushServer(object):
             while self.server_running:
                 read_ready, _, _ = select.select(self.connections,
                                                  [], [], 1)
+
                 for sock in read_ready:
                     if not self.server_running:
                         break
 
                     if sock == self.server_socket:
-
                         new_socket, addr = self.server_socket.accept()
                         self.connections.append(new_socket)
                     else:
                         try:
                             data = sock.recv(4096)
-                        except:
-                            try:
+                            if not data:
                                 self.connections.remove(sock)
-                            except ValueError:
-                                pass
-
-                            continue
-                        if data and data == 'CLOSE':
-                            sock.send('ACK')
+                                sock.close()
+                        except:
                             try:
                                 self.connections.remove(sock)
                             except ValueError:
                                 pass
-                            sock.close()
+                            finally:
+                                sock.close()
 
         except Exception as e:
             raise RuntimeError('Exception ocurred in listen() of pushserver '
-- 
2.9.3

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
Re: [Kimchi-devel] [PATCH] [WoK] Bug fix #217: Fixing select() waking up
Posted by Aline Manera 6 years, 11 months ago
Applied. Thanks.

Regards,

Aline Manera

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel