Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-637

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

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.1, 0.2
    • Fix Version/s: 0.1
    • Component/s: Python - Library
    • Labels:
      None
    • Environment:

      All hardware/os combos, Python server

    • Patch Info:
      Patch Available

      Description

      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:

      1. 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:

      1. it was a oneway request, do not write answer
        self.status = WAIT_LEN
        + self.message = ''
        else:
        self.status = SEND_ANSWER
        self.wake_up()

        Attachments

        1. thrift-637.txt
          1 kB
          Todd Lipcon

          Activity

            People

            • Assignee:
              tlipcon Todd Lipcon
              Reporter:
              arvinds Arvind Sundararajan
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: