summaryrefslogtreecommitdiffstats
path: root/filedistribution
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-09-15 08:09:43 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2016-09-15 08:09:43 +0000
commit674903e4f9e4206f7a519bab90422a5851fc0820 (patch)
treec10051da0bb17d80cbaf5babfcf10dd160a53d3a /filedistribution
parent090273a07b00760a2b96c5de2becbb93a529dda4 (diff)
Detect if it took too long to shutdown, produce coredump in that case
Diffstat (limited to 'filedistribution')
-rw-r--r--filedistribution/src/vespa/filedistribution/model/zkfacade.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/filedistribution/src/vespa/filedistribution/model/zkfacade.cpp b/filedistribution/src/vespa/filedistribution/model/zkfacade.cpp
index 8c67dba3150..9bf29ab1854 100644
--- a/filedistribution/src/vespa/filedistribution/model/zkfacade.cpp
+++ b/filedistribution/src/vespa/filedistribution/model/zkfacade.cpp
@@ -9,12 +9,14 @@
#include <cassert>
#include <cstdio>
#include <sstream>
+#include <thread>
#include <boost/throw_exception.hpp>
#include <boost/function_output_iterator.hpp>
#include <zookeeper/zookeeper.h>
#include <vespa/filedistribution/common/logfwd.h>
#include <vespa/defaults.h>
+#include <vespa/vespalib/util/sync.h>
typedef std::unique_lock<std::mutex> UniqueLock;
@@ -253,8 +255,15 @@ ZKFacade::ZKFacade(const std::string& zkservers)
ZKFacade::~ZKFacade() {
disableRetries();
_watchersEnabled = false;
- zookeeper_close(_zhandle);
- LOGFWD(debug, "Zookeeper connection closed successfully.");
+ vespalib::Gate done;
+ std::thread closer([&done, zhandle=_zhandle] () { zookeeper_close(zhandle); done.countDown(); });
+ if ( ! done.await(50*1000) ) {
+ LOGFWD(debug, "Zookeeper connection closed successfully.");
+ } else {
+ LOGFWD(error, "Not able to close down zookeeper. Dumping core so you can figure out what is wrong");
+ abort();
+ }
+ closer.join();
}
const std::string