Skip to content

Commit 0825ca3

Browse files
committed
THRIFT-5841 possible init/deinit conflict with manual initialization flag
Client: cpp Patch: Jens Geyer This closes #3077
1 parent 645467e commit 0825ca3

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

lib/cpp/src/thrift/TOutput.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
namespace apache {
3232
namespace thrift {
3333

34-
THRIFT_EXPORT TOutput GlobalOutput;
34+
/*THRIFT_EXPORT*/ TOutput GlobalOutput; // if you need this exported, build your own wrapper lib around and export it yourself
3535

3636
TOutput::TOutput() : f_(&errorTimeWrapper) {}
3737

lib/cpp/src/thrift/TOutput.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#ifndef _THRIFT_OUTPUT_H_
2121
#define _THRIFT_OUTPUT_H_ 1
2222

23-
#include <thrift/thrift_export.h>
23+
//#include <thrift/thrift_export.h>
2424

2525
namespace apache {
2626
namespace thrift {
@@ -53,7 +53,7 @@ class TOutput {
5353
void (*f_)(const char*);
5454
};
5555

56-
THRIFT_EXPORT extern TOutput GlobalOutput;
56+
/*THRIFT_EXPORT*/ extern TOutput GlobalOutput; // if you need this exported, build your own wrapper lib around and export it yourself
5757
}
5858
} // namespace apache::thrift
5959

lib/cpp/src/thrift/transport/TSSLServerSocket.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
#include <thrift/thrift_export.h>
20+
//#include <thrift/thrift_export.h>
2121
#include <thrift/transport/TSSLServerSocket.h>
2222
#include <thrift/transport/TSSLSocket.h>
2323

lib/cpp/src/thrift/transport/TSSLSocket.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,13 @@ unsigned int TSSLSocket::waitForEvent(bool wantRead) {
875875
uint64_t TSSLSocketFactory::count_ = 0;
876876
Mutex TSSLSocketFactory::mutex_;
877877
bool TSSLSocketFactory::manualOpenSSLInitialization_ = false;
878+
bool TSSLSocketFactory::didWeInitializeOpenSSL_ = false;
878879

879880
TSSLSocketFactory::TSSLSocketFactory(SSLProtocol protocol) : server_(false) {
880881
Guard guard(mutex_);
881882
if (count_ == 0) {
882883
if (!manualOpenSSLInitialization_) {
884+
didWeInitializeOpenSSL_ = true;
883885
initializeOpenSSL();
884886
}
885887
randomize();
@@ -892,8 +894,9 @@ TSSLSocketFactory::~TSSLSocketFactory() {
892894
Guard guard(mutex_);
893895
ctx_.reset();
894896
count_--;
895-
if (count_ == 0 && !manualOpenSSLInitialization_) {
897+
if (count_ == 0 && didWeInitializeOpenSSL_) {
896898
cleanupOpenSSL();
899+
didWeInitializeOpenSSL_ = false;
897900
}
898901
}
899902

lib/cpp/src/thrift/transport/TSSLSocket.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ class TSSLSocketFactory {
327327
std::shared_ptr<AccessManager> access_;
328328
static concurrency::Mutex mutex_;
329329
static uint64_t count_;
330-
THRIFT_EXPORT static bool manualOpenSSLInitialization_;
330+
/*THRIFT_EXPORT*/ static bool manualOpenSSLInitialization_; // questionable to export a private member
331+
static bool didWeInitializeOpenSSL_; // in that case we also perform de-init
331332
void setup(std::shared_ptr<TSSLSocket> ssl);
332333
static int passwordCallback(char* password, int size, int, void* data);
333334
};

0 commit comments

Comments
 (0)