rename ctdb.h to ctdb_protocol.h
[sahlberg/ctdb.git] / server / ctdb_lockwait.c
index 5b0019836e8f097f0ea816222eeee7ed55e74856..5128a3e05ea04774b58d92bddd46b4e09bd452a5 100644 (file)
@@ -23,7 +23,8 @@
 #include "system/wait.h"
 #include "db_wrap.h"
 #include "lib/tdb/include/tdb.h"
-#include "../include/ctdb_private.h"
+#include "include/ctdb_protocol.h"
+#include "include/ctdb_private.h"
 
 
 struct lockwait_handle {
@@ -53,7 +54,7 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde,
        key.dptr = talloc_memdup(tmp_ctx, key.dptr, key.dsize);
 
        talloc_set_destructor(h, NULL);
-       ctdb_latency(&h->ctdb->statistics.max_lockwait_latency, h->start_time);
+       ctdb_latency(h->ctdb_db, "lockwait", &h->ctdb->statistics.max_lockwait_latency, h->start_time);
        h->ctdb->statistics.pending_lockwait_calls--;
 
        /* the handle needs to go away when the context is gone - when
@@ -72,7 +73,6 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde,
        tdb_chainlock_unmark(tdb, key);
 
        kill(child, SIGKILL);
-       waitpid(child, NULL, 0);
        talloc_free(tmp_ctx);
 }
 
@@ -80,7 +80,6 @@ static int lockwait_destructor(struct lockwait_handle *h)
 {
        h->ctdb->statistics.pending_lockwait_calls--;
        kill(h->child, SIGKILL);
-       waitpid(h->child, NULL, 0);
        return 0;
 }
 
@@ -148,6 +147,10 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
        }
 
        close(result->fd[1]);
+       set_close_on_exec(result->fd[0]);
+
+       DEBUG(DEBUG_DEBUG, (__location__ " Created PIPE FD:%d to child lockwait process\n", result->fd[0]));
+
        talloc_set_destructor(result, lockwait_destructor);
 
        result->fde = event_add_fd(ctdb_db->ctdb->ev, result, result->fd[0],