You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Ben Craig (JIRA)" <ji...@apache.org> on 2013/03/18 17:06:15 UTC

[jira] [Commented] (THRIFT-1892) Socket timeouts are declared in milli-seconds, but are actually set in micro-seconds

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

Ben Craig commented on THRIFT-1892:
-----------------------------------

I looked at the code, and timeouts are wrong for both connection timeouts (handled in config.h) and send / recv timeouts (handled in TSocket.cpp), but these two are wrong for different reasons, and it isn't as simple as milliseconds being treated as microseconds.

In config.h poll_win32 is turning a millisecond timeout "int" into a timeval structure, and doing so incorrectly.  It fills in the timeval via {timeout/1000, timeout*1000}, but should do something like {timeout/1000, (timeout%1000)*1000}.

For the send and recv timeouts, setsockopt is called with a timeval, but WinSock is expecting a DWORD of milliseconds.  I suspect it is using the seconds parameter of the structure instead, which would mean that the value is off by a factor of 1000, matching the behavior observed in the bug description.
                
> Socket timeouts are declared in milli-seconds, but are actually set in micro-seconds
> ------------------------------------------------------------------------------------
>
>                 Key: THRIFT-1892
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1892
>             Project: Thrift
>          Issue Type: Bug
>          Components: C++ - Library
>    Affects Versions: 0.9
>         Environment: Windows 8 x64
>            Reporter: Alexander
>            Priority: Minor
>              Labels: cpp, socket, timeout
>
> Socket timeouts are declared in milliseconds in TSocket.h:
>   /**
>    * Set the connect timeout
>    */
>   void setConnTimeout(int ms);
>   /**
>    * Set the receive timeout
>    */
>   void setRecvTimeout(int ms);
>   /**
>    * Set the send timeout
>    */
>   void setSendTimeout(int ms);
> But, when i set timeout which is supposed to be 5000 seconds, and make a call to the service function that intentionally hangs, ETIMEDOUT exception occurs precisely after 5 seconds.
>   socket->setConnTimeout(5*1000*1000);
>   socket->setRecvTimeout(5*1000*1000);
>   socket->setSendTimeout(5*1000*1000);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira