summaryrefslogtreecommitdiff
path: root/ctdb/server/ctdb_cluster_mutex.c
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2016-06-01 19:05:47 +1000
committerMartin Schwenke <martins@samba.org>2016-06-08 00:51:29 +0200
commit95a7920d2281e05889ff66595c7470f9d6a42295 (patch)
tree4a61ad9c6abc9748ddcbd2f09b50f9a72fd3674d /ctdb/server/ctdb_cluster_mutex.c
parent4f0ca0107c83ca0da3e676975543adcbb122b0b9 (diff)
downloadsamba-95a7920d2281e05889ff66595c7470f9d6a42295.tar.gz
ctdb-cluster-mutex: Register an extra handler for when mutex is lost
Pass NULL if not needed. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/server/ctdb_cluster_mutex.c')
-rw-r--r--ctdb/server/ctdb_cluster_mutex.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/ctdb/server/ctdb_cluster_mutex.c b/ctdb/server/ctdb_cluster_mutex.c
index fbeeb92fb6b..fa70a001e81 100644
--- a/ctdb/server/ctdb_cluster_mutex.c
+++ b/ctdb/server/ctdb_cluster_mutex.c
@@ -40,6 +40,8 @@ struct ctdb_cluster_mutex_handle {
struct ctdb_context *ctdb;
cluster_mutex_handler_t handler;
void *private_data;
+ cluster_mutex_lost_handler_t lost_handler;
+ void *lost_data;
int fd[2];
struct tevent_timer *te;
struct tevent_fd *fde;
@@ -94,6 +96,13 @@ static void cluster_mutex_handler(struct tevent_context *ev,
/* Don't call the handler more than once. It only exists to
* process the initial response from the helper. */
if (h->have_response) {
+ /* Only deal with EOF due to process exit. Silently
+ * ignore any other output. */
+ if (ret == 0) {
+ if (h->lost_handler != NULL) {
+ h->lost_handler(h->lost_data);
+ }
+ }
return;
}
h->have_response = true;
@@ -180,7 +189,9 @@ ctdb_cluster_mutex(TALLOC_CTX *mem_ctx,
const char *argstring,
int timeout,
cluster_mutex_handler_t handler,
- void *private_data)
+ void *private_data,
+ cluster_mutex_lost_handler_t lost_handler,
+ void *lost_data)
{
struct ctdb_cluster_mutex_handle *h;
char **args;
@@ -264,6 +275,8 @@ ctdb_cluster_mutex(TALLOC_CTX *mem_ctx,
h->ctdb = ctdb;
h->handler = handler;
h->private_data = private_data;
+ h->lost_handler = lost_handler;
+ h->lost_data = lost_data;
return h;
}