Change in vdsm[master]: xmlrpc: detecting loop on centos7

piotr.kliczewski at gmail.com piotr.kliczewski at gmail.com
Mon Mar 30 12:03:50 UTC 2015


Piotr Kliczewski has uploaded a new change for review.

Change subject: xmlrpc: detecting loop on centos7
......................................................................

xmlrpc: detecting loop on centos7

When we process newly incoming connection we receive read event and we
detect xmlrpc protocol and we call handle_dispatcher which removes
dispatcher from further processing in asyncore loop and pass the socket
to xmlrpc implementation which handles requests in different thread.
After handling read we check whether there is more data awaits
processing (buffer to small to handle all of it). When xmlrpc impl
slowly prcesses a request we run several iterations of handle_read which
leads to detection loop.

When we detect xmlrpc protocol we do not want to get trapped by
handle_read loop and for jsonrpc a dispatcher generates another read
event which finalizes processing.


Change-Id: I238d10b3bd8aaf8baac55ec81a7d406609e544e6
Signed-off-by: pkliczewski <piotr.kliczewski at gmail.com>
---
M lib/yajsonrpc/betterAsyncore.py
M vdsm/protocoldetector.py
2 files changed, 13 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/43/39343/1

diff --git a/lib/yajsonrpc/betterAsyncore.py b/lib/yajsonrpc/betterAsyncore.py
index ad11cc1..84c743d 100644
--- a/lib/yajsonrpc/betterAsyncore.py
+++ b/lib/yajsonrpc/betterAsyncore.py
@@ -96,6 +96,10 @@
 
         self.handle_read()
 
+        if hasattr(self.__impl, "recently_detected"):
+            if self.__impl.recently_detected():
+                return
+
         # we need to check whether there is pending function on
         # our fd because we use eventfds which do not provide it
         if hasattr(self.socket, "pending"):
diff --git a/vdsm/protocoldetector.py b/vdsm/protocoldetector.py
index e3c8312..a2d2c8f 100644
--- a/vdsm/protocoldetector.py
+++ b/vdsm/protocoldetector.py
@@ -80,6 +80,7 @@
 
     def __init__(self, detectors, timeout=None):
         self._detectors = detectors
+        self._recently_detected = False
         self._required_size = max(h.REQUIRED_SIZE for h in self._detectors)
         self.log.debug("Using required_size=%d", self._required_size)
         self._give_up_at = monotonic_time() + timeout
@@ -89,6 +90,13 @@
 
     def next_check_interval(self):
         return min(self._give_up_at - monotonic_time(), 0)
+
+    def recently_detected(self):
+        if self._recently_detected:
+            self._recently_detected = False
+            return True
+
+        return False
 
     def handle_read(self, dispatcher):
         sock = dispatcher.socket
@@ -117,6 +125,7 @@
                     port
                 )
                 detector.handle_dispatcher(dispatcher, (host, port))
+                self._recently_detected = True
                 break
         else:
             self.log.warning("Unrecognized protocol: %r", data)


-- 
To view, visit https://gerrit.ovirt.org/39343
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I238d10b3bd8aaf8baac55ec81a7d406609e544e6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <piotr.kliczewski at gmail.com>


More information about the vdsm-patches mailing list