]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
in ctdb_control_persistent_store() we must talloc_steal() the pointer to
authorRonnie Sahlberg <sahlberg@ronnie>
Fri, 21 Sep 2007 05:19:33 +0000 (15:19 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Fri, 21 Sep 2007 05:19:33 +0000 (15:19 +1000)
c   to prevent it from being immediately freed (and our persistent store
state with it) if we need to wait asynchronously for other nodes before
we can reply back to the client

(This used to be ctdb commit fa5915280933e4d2e7d4d07199829c9c2b87a335)

ctdb/server/ctdb_persistent.c

index 7d9bd48a33a2f085261a7ef2f29abc503c0ca450..20c1784c19d22dc80a65a5dedee47efd260e20c3 100644 (file)
@@ -44,6 +44,7 @@ static void ctdb_persistent_callback(struct ctdb_context *ctdb,
 {
        struct ctdb_persistent_state *state = talloc_get_type(private_data, 
                                                              struct ctdb_persistent_state);
+
        if (status != 0) {
                DEBUG(0,("ctdb_persistent_callback failed with status %d (%s)\n",
                         status, errormsg));
@@ -57,6 +58,18 @@ static void ctdb_persistent_callback(struct ctdb_context *ctdb,
        }
 }
 
+/*
+  called if persistent store times out
+ */
+static void ctdb_persistent_store_timeout(struct event_context *ev, struct timed_event *te, 
+                                        struct timeval t, void *private_data)
+{
+       struct ctdb_persistent_state *state = talloc_get_type(private_data, struct ctdb_persistent_state);
+       
+       ctdb_request_control_reply(state->ctdb, state->c, NULL, -1, "timeout in ctdb_persistent_state");
+
+       talloc_free(state);
+}
 
 /*
   store a persistent record - called from a ctdb client when it has updated
@@ -75,7 +88,7 @@ int32_t ctdb_control_persistent_store(struct ctdb_context *ctdb,
        CTDB_NO_MEMORY(ctdb, state);
 
        state->ctdb = ctdb;
-       state->c    = c;
+       state->c    = talloc_steal(state, c);
 
        for (i=0;i<ctdb->num_nodes;i++) {
                struct ctdb_node *node = ctdb->nodes[i];
@@ -110,6 +123,12 @@ int32_t ctdb_control_persistent_store(struct ctdb_context *ctdb,
        
        /* we need to wait for the replies */
        *async_reply = true;
+
+       /* but we wont wait forever */
+       event_add_timed(ctdb->ev, state, 
+                       timeval_current_ofs(ctdb->tunable.control_timeout, 0),
+                       ctdb_persistent_store_timeout, state);
+
        return 0;
 }