mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
- catch a case where the client disconnects during a call
- track all talloc memory, using NULL context (This used to be ctdb commit bf89c56002f5311520e91cb367753bc46e5dddc9)
This commit is contained in:
parent
6c56e9d347
commit
bf9e33d4cf
@ -71,7 +71,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
|
||||
case CTDB_CONTROL_STATISTICS: {
|
||||
CHECK_CONTROL_DATA_SIZE(0);
|
||||
ctdb->statistics.memory_used = talloc_total_size(ctdb);
|
||||
ctdb->statistics.memory_used = talloc_total_size(NULL);
|
||||
ctdb->statistics.frozen = (ctdb->freeze_mode == CTDB_FREEZE_FROZEN);
|
||||
ctdb->statistics.recovering = (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE);
|
||||
outdata->dptr = (uint8_t *)&ctdb->statistics;
|
||||
|
@ -288,9 +288,37 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
|
||||
client->ctdb->statistics.pending_calls--;
|
||||
}
|
||||
|
||||
struct ctdb_daemon_packet_wrap {
|
||||
struct ctdb_context *ctdb;
|
||||
uint32_t client_id;
|
||||
};
|
||||
|
||||
/*
|
||||
a wrapper to catch disconnected clients
|
||||
*/
|
||||
static void daemon_incoming_packet_wrap(void *p, struct ctdb_req_header *hdr)
|
||||
{
|
||||
struct ctdb_client *client;
|
||||
struct ctdb_daemon_packet_wrap *w = talloc_get_type(p,
|
||||
struct ctdb_daemon_packet_wrap);
|
||||
if (w == NULL) {
|
||||
DEBUG(0,(__location__ " Bad packet type '%s'\n", talloc_get_name(p)));
|
||||
return;
|
||||
}
|
||||
|
||||
client = ctdb_reqid_find(w->ctdb, w->client_id, struct ctdb_client);
|
||||
if (client == NULL) {
|
||||
DEBUG(0,(__location__ " Packet for disconnected client %u\n",
|
||||
w->client_id));
|
||||
talloc_free(w);
|
||||
return;
|
||||
}
|
||||
talloc_free(w);
|
||||
|
||||
/* process it */
|
||||
daemon_incoming_packet(client, hdr);
|
||||
}
|
||||
|
||||
static void daemon_request_call_from_client(struct ctdb_client *client,
|
||||
struct ctdb_req_call *c);
|
||||
|
||||
/*
|
||||
this is called when the ctdb daemon received a ctdb request call
|
||||
@ -307,6 +335,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
|
||||
TDB_DATA key, data;
|
||||
int ret;
|
||||
struct ctdb_context *ctdb = client->ctdb;
|
||||
struct ctdb_daemon_packet_wrap *w;
|
||||
|
||||
ctdb->statistics.total_calls++;
|
||||
ctdb->statistics.pending_calls++;
|
||||
@ -322,15 +351,23 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
|
||||
key.dptr = c->data;
|
||||
key.dsize = c->keylen;
|
||||
|
||||
w = talloc(ctdb, struct ctdb_daemon_packet_wrap);
|
||||
CTDB_NO_MEMORY_VOID(ctdb, w);
|
||||
|
||||
w->ctdb = ctdb;
|
||||
w->client_id = client->client_id;
|
||||
|
||||
ret = ctdb_ltdb_lock_fetch_requeue(ctdb_db, key, &header,
|
||||
(struct ctdb_req_header *)c, &data,
|
||||
daemon_incoming_packet, client, True);
|
||||
daemon_incoming_packet_wrap, w, True);
|
||||
if (ret == -2) {
|
||||
/* will retry later */
|
||||
ctdb->statistics.pending_calls--;
|
||||
return;
|
||||
}
|
||||
|
||||
talloc_free(w);
|
||||
|
||||
if (ret != 0) {
|
||||
DEBUG(0,(__location__ " Unable to fetch record\n"));
|
||||
ctdb->statistics.pending_calls--;
|
||||
|
@ -137,6 +137,8 @@ int main(int argc, const char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
talloc_enable_null_tracking();
|
||||
|
||||
ctdb_block_signal(SIGPIPE);
|
||||
|
||||
ev = event_context_init(NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user