Bug in TNonblockingServer.py for services with both oneway and regular requests 
--------------------------------------------------------------------------------

                 Key: THRIFT-637
                 URL: https://issues.apache.org/jira/browse/THRIFT-637
             Project: Thrift
          Issue Type: Bug
          Components: Library (Python)
    Affects Versions: 0.1, 0.2
         Environment: All hardware/os combos, Python server
            Reporter: Arvind Sundararajan


If you implement a service with TNonblockingServer.py and have both oneway and 
regular methods in your interface, the first regular request after a oneway 
request will fail with the error:

[TNonblockingServer.py :113 ] - 2009-11-26 13:58:01,829 - ERROR - can't read 
frame size from socket

This is because self.message is not cleaned up when there is no reply.

The implementation seems to start constructing a message in response
to a oneway request and then gives up once it realizes it is a oneway
request

 def ready(self, all_ok, message):

....
       self.message = struct.pack('!i', len(message)) + message
       if len(message) == 0:
           # it was a oneway request, do not write answer
           self.status = WAIT_LEN

Then for the next regular message len(self.message) == 4 and self._read_len is 
very defensive about
reading only the exact right amount of data from the socket.

My patch is simple and seems to fix the problem:

> svn diff
Index: lib/py/src/server/TNonblockingServer.py
===================================================================
--- lib/py/src/server/TNonblockingServer.py     (revision 884669)
+++ lib/py/src/server/TNonblockingServer.py     (working copy)
@@ -182,6 +182,7 @@
        if len(message) == 0:
            # it was a oneway request, do not write answer
            self.status = WAIT_LEN
+            self.message = ''
        else:
            self.status = SEND_ANSWER
        self.wake_up()


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to