------------------------------------------------------------
revno: 635
revision-id: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: Andrew Tridgell <[EMAIL PROTECTED]>
branch nick: tridge
timestamp: Fri 2007-09-21 15:32:11 +1000
message:
  merge bugfix from ronnie
modified:
  server/ctdb_persistent.c       
ctdb_persistent.c-20070920053845-u2ggm5relkdor3xg-1
    ------------------------------------------------------------
    revno: 432.1.294
    revision-id: [EMAIL PROTECTED]
    parent: [EMAIL PROTECTED]
    committer: Ronnie Sahlberg <[EMAIL PROTECTED]>
    branch nick: ctdb
    timestamp: Fri 2007-09-21 15:19:33 +1000
    message:
      in ctdb_control_persistent_store() we must talloc_steal() the pointer to 
      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
    modified:
      server/ctdb_persistent.c       
ctdb_persistent.c-20070920053845-u2ggm5relkdor3xg-1
=== modified file 'server/ctdb_persistent.c'
--- a/server/ctdb_persistent.c  2007-09-21 02:24:02 +0000
+++ b/server/ctdb_persistent.c  2007-09-21 05:19:33 +0000
@@ -44,6 +44,7 @@
 {
        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 @@
        }
 }
 
+/*
+  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 @@
        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 @@
        
        /* 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;
 }
 

Reply via email to