Github user nsuke commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/628#discussion_r45580689
  
    --- Diff: lib/cpp/src/thrift/server/TNonblockingServer.cpp ---
    @@ -1105,10 +1113,17 @@ void TNonblockingServer::listenSocket(THRIFT_SOCKET 
s) {
       serverSocket_ = s;
     
       if (!port_) {
    -    sockaddr_in addr;
    -    socklen_t size = sizeof(addr);
    -    if (!getsockname(serverSocket_, reinterpret_cast<sockaddr*>(&addr), 
&size)) {
    -      listenPort_ = ntohs(addr.sin_port);
    +    #ifdef _WIN32
    +      struct sockaddr_storage addr;
    +      struct sockaddr_in *pAddr = (sockaddr_in *) &addr;
    +      socklen_t size = sizeof(addr);
    +    #else
    +      struct sockaddr_in addr;
    +      struct sockaddr_in *pAddr = &addr;
    +      socklen_t size = sizeof(addr);
    +    #endif
    --- End diff --
    
    OK, let's do it, then.
    Here again, I prefer keeping your version only rather than `#ifdef` for the 
sake of readability over saving transitive ~100 bytes allocation, unless others 
disagree.
    What do you think ? Do you have any concern ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to