You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2020/09/15 18:40:15 UTC

[thrift] branch master updated: TServerSocket.cpp: Ensure the server is really listening (via helper variable listening_) Client: cpp Patch: Mario Emmenlauer

This is an automated email from the ASF dual-hosted git repository.

jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new dd6c8c1  TServerSocket.cpp: Ensure the server is really listening (via helper variable listening_) Client: cpp Patch: Mario Emmenlauer
dd6c8c1 is described below

commit dd6c8c1069d74f47e81f47dc89285edf906a464e
Author: Mario Emmenlauer <me...@biodataanalysis.de>
AuthorDate: Wed Sep 9 13:43:15 2020 +0200

    TServerSocket.cpp: Ensure the server is really listening (via helper variable listening_)
    Client: cpp
    Patch: Mario Emmenlauer
    
    This closes #2232
---
 lib/cpp/src/thrift/transport/TServerSocket.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp
index 6b76525..c917538 100644
--- a/lib/cpp/src/thrift/transport/TServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp
@@ -167,7 +167,13 @@ TServerSocket::~TServerSocket() {
 }
 
 bool TServerSocket::isOpen() const {
-  return (serverSocket_ != THRIFT_INVALID_SOCKET);
+  if (serverSocket_ == THRIFT_INVALID_SOCKET)
+    return false;
+
+  if (!listening_)
+    return false;
+
+  return true;
 }
 
 void TServerSocket::setSendTimeout(int sendTimeout) {
@@ -324,7 +330,6 @@ void TServerSocket::_setup_tcp_sockopts() {
 }
 
 void TServerSocket::listen() {
-  listening_ = true;
 #ifdef _WIN32
   TWinsockSingleton::create();
 #endif // _WIN32
@@ -538,6 +543,7 @@ void TServerSocket::listen() {
   }
 
   // The socket is now listening!
+  listening_ = true;
 }
 
 int TServerSocket::getPort() {