You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Ivan Murashko (JIRA)" <ji...@apache.org> on 2011/01/07 21:23:45 UTC
[jira] Commented: (THRIFT-966) Bind to zero port
[ https://issues.apache.org/jira/browse/THRIFT-966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978945#action_12978945 ]
Ivan Murashko commented on THRIFT-966:
--------------------------------------
The getBindPort() method should be called exactly after TServerSocket::listen() call. In other case the return value will be -1 (same as in the constructor).
Somebody can use spin-lock to wait until the value become greater than 0 but in my case I used TServerEventHandler::preServe() hook to retrieve the real port number and store it at a shared place where client can find it. The solution worked without any issues for me.
> Bind to zero port
> -----------------
>
> Key: THRIFT-966
> URL: https://issues.apache.org/jira/browse/THRIFT-966
> Project: Thrift
> Issue Type: Improvement
> Components: C++ - Library
> Reporter: Ivan Murashko
> Fix For: 0.7
>
> Attachments: bindinfo_retrieval.diff
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> apache::thrift::transport::TServerSocket class has a possibility to set 0 as port number. In this case bind will assign a free port number. Unfortunately there is no possibility to retrieve the assigned port number from the TServerSocket class. Thus clients will not be able to connect the server.
> The suggested patch introduces apache::thrift::transport::TServerSocket::getBindPort() method that return the assigned port number or -1 in the case of any failure or when the port has not been assigned yet.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.