]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
- fixed a crash bug after client disconnect in ctdb_control
authorAndrew Tridgell <tridge@samba.org>
Fri, 4 May 2007 22:33:35 +0000 (08:33 +1000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 4 May 2007 22:33:35 +0000 (08:33 +1000)
- added total memory used to ctdb_control status output

(This used to be ctdb commit a99ffe4372edc63d83d8c8ebf9a60b3413301f5a)

ctdb/common/ctdb_control.c
ctdb/include/ctdb_private.h
ctdb/tools/ctdb_control.c

index 837f8ccc88e3104aa9767b5f2eac26e9d249c952..41bab7e87ff521e83573ebba47d11668e8a45c40 100644 (file)
@@ -158,6 +158,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
        case CTDB_CONTROL_STATUS: {
                CHECK_CONTROL_DATA_SIZE(0);
                ctdb->status.controls.status++;
+               ctdb->status.memory_used = talloc_total_size(ctdb);
                outdata->dptr = (uint8_t *)&ctdb->status;
                outdata->dsize = sizeof(ctdb->status);
                return 0;
@@ -499,8 +500,11 @@ void ctdb_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
        data.dptr = &c->data[0];
        data.dsize = c->datalen;
 
+       /* make state a child of the packet, so it goes away when the packet
+          is freed. */
+       talloc_steal(hdr, state);
+
        state->callback(ctdb, c->status, data, state->private_data);
-       talloc_free(state);
 }
 
 static int ctdb_control_destructor(struct ctdb_control_state *state)
@@ -528,7 +532,9 @@ int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
                return -1;
        }
 
-       state = talloc(ctdb, struct ctdb_control_state);
+       /* the state is made a child of private_data if possible. This means any reply
+          will be discarded if the private_data goes away */
+       state = talloc(private_data?private_data:ctdb, struct ctdb_control_state);
        CTDB_NO_MEMORY(ctdb, state);
 
        state->reqid = ctdb_reqid_new(ctdb, state);
index 5bdca6a3ac96c1fb6b24b18c4078f0b78ad9e267..b11f5072219f4cefd46dd500529d7795f0093331 100644 (file)
@@ -175,6 +175,7 @@ struct ctdb_status {
        uint32_t lockwait_calls;
        uint32_t traverse_calls;
        uint32_t pending_lockwait_calls;
+       uint32_t memory_used;
        uint32_t __last_counter; /* hack for control_status_all */
        uint32_t max_hop_count;
        double max_call_latency;
index 2e2c8efa3c7efbad27bf0321e77f6a0fdf10e173..8f4ed3f70df9da3be629c171ad0824c0689d1070 100644 (file)
@@ -135,6 +135,7 @@ static void show_status(struct ctdb_status *s)
                STATUS_FIELD(lockwait_calls),
                STATUS_FIELD(traverse_calls),
                STATUS_FIELD(pending_lockwait_calls),
+               STATUS_FIELD(memory_used),
                STATUS_FIELD(max_hop_count),
        };
        printf("CTDB version %u\n", CTDB_VERSION);