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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8973406  Protect against double joining the worker thread in (#4084)
8973406 is described below

commit 897340632fc1b5bfd2eee28d0da2278c7bb44169
Author: Nick Rivera <[email protected]>
AuthorDate: Mon Apr 22 16:57:17 2019 -0700

    Protect against double joining the worker thread in (#4084)
    
    ExecutorService::close() because joining is not re-entrant on Windows
---
 pulsar-client-cpp/lib/ExecutorService.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pulsar-client-cpp/lib/ExecutorService.cc 
b/pulsar-client-cpp/lib/ExecutorService.cc
index 194820a..0ef77b3 100644
--- a/pulsar-client-cpp/lib/ExecutorService.cc
+++ b/pulsar-client-cpp/lib/ExecutorService.cc
@@ -55,9 +55,13 @@ DeadlineTimerPtr ExecutorService::createDeadlineTimer() {
 }
 
 void ExecutorService::close() {
-    io_service_.stop();
-    work_.reset();
-    worker_.join();
+    // Ensure this service has not already been closed. This is
+    // because worker_.join() is not re-entrant on Windows
+    if (work_) {
+        io_service_.stop();
+        work_.reset();
+        worker_.join();
+    }
 }
 
 void ExecutorService::postWork(std::function<void(void)> task) { 
io_service_.post(task); }

Reply via email to