Rev 253: - fixed a crash bug after client disconnect in ctdb_control in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Fri May 4 22:33:36 GMT 2007


------------------------------------------------------------
revno: 253
revision-id: tridge at samba.org-20070504223335-oai3wi0jsmp8ywwp
parent: tridge at samba.org-20070504221154-bzrdobzto7dh90ze
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Sat 2007-05-05 08:33:35 +1000
message:
  - fixed a crash bug after client disconnect in ctdb_control
  - added total memory used to ctdb_control status output
modified:
  common/ctdb_control.c          ctdb_control.c-20070426122724-j6gkpiofhbwdin63-1
  include/ctdb_private.h         ctdb_private.h-20061117234101-o3qt14umlg9en8z0-13
  tools/ctdb_control.c           ctdb_control.c-20070426122705-9ehj1l5lu2gn9kuj-1
=== modified file 'common/ctdb_control.c'
--- a/common/ctdb_control.c	2007-05-04 22:11:54 +0000
+++ b/common/ctdb_control.c	2007-05-04 22:33:35 +0000
@@ -158,6 +158,7 @@
 	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 @@
 	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 @@
 		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);

=== modified file 'include/ctdb_private.h'
--- a/include/ctdb_private.h	2007-05-04 22:11:54 +0000
+++ b/include/ctdb_private.h	2007-05-04 22:33:35 +0000
@@ -175,6 +175,7 @@
 	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;

=== modified file 'tools/ctdb_control.c'
--- a/tools/ctdb_control.c	2007-05-04 22:11:54 +0000
+++ b/tools/ctdb_control.c	2007-05-04 22:33:35 +0000
@@ -135,6 +135,7 @@
 		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);



More information about the samba-cvs mailing list