You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Todd Lipcon (JIRA)" <ji...@apache.org> on 2009/12/01 08:30:20 UTC
[jira] Updated: (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:all-tabpanel ]
Todd Lipcon updated THRIFT-637:
-------------------------------
Attachment: thrift-637.txt
Thanks for the bug report. I fixed it slightly differently than your proposal, and also added a unit test.
To test:
{noformat}
$ cd test
$ thrift -gen py ThriftTest.thrift
$ cd py
$ PYTHONPATH=../gen-py python TestServer.py TNonblockingServer &
$ PYTHONPATH=../gen-py python TestClient.py --framed
{noformat}
Without the patch, the new unit test fails. With, it passes.
> 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
> 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.