You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "David Reiss (JIRA)" <ji...@apache.org> on 2009/12/01 18:26:21 UTC

[jira] Commented: (THRIFT-637) Bug in TNonblockingServer.py for services with both oneway and regular requests

    [ https://issues.apache.org/jira/browse/THRIFT-637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12784297#action_12784297 ] 

David Reiss commented on THRIFT-637:
------------------------------------

LGTM.  Want me to commit, or wait for you to get your account?  Also, can you change the message to

THRIFT-637. python: Fix mixing of oneway and regular requests in TNonblockingServer

?  I think having the language at the beginning makes it easier to skim logs.

> 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
>            Assignee: Todd Lipcon
>         Attachments: thrift-637.txt
>
>
> 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.