summaryrefslogtreecommitdiffstats
path: root/ctdb/common/ctdb_daemon.c
diff options
context:
space:
mode:
authorRonnie sahlberg <ronniesahlberg@gmail.com>2007-04-18 11:33:19 +1000
committerRonnie sahlberg <ronniesahlberg@gmail.com>2007-04-18 11:33:19 +1000
commitc6f2050e05c9ee5bf282233ff151c02cefb558d9 (patch)
tree9f5eaced513fd15a4021056eb9fe5f0d9b4a426a /ctdb/common/ctdb_daemon.c
parent1739dbd31760d906e89326d700f108e0c7669721 (diff)
parent8f059f4d91ee8df59eb9ae4052ca8f5afa392c3b (diff)
downloadsamba-c6f2050e05c9ee5bf282233ff151c02cefb558d9.tar.gz
samba-c6f2050e05c9ee5bf282233ff151c02cefb558d9.tar.xz
samba-c6f2050e05c9ee5bf282233ff151c02cefb558d9.zip
merge from tridge
(This used to be ctdb commit e83db4d76ea498413ba4314e937d0ff298bd4cb6)
Diffstat (limited to 'ctdb/common/ctdb_daemon.c')
-rw-r--r--ctdb/common/ctdb_daemon.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/ctdb/common/ctdb_daemon.c b/ctdb/common/ctdb_daemon.c
index 94aba21ffb..03cc1777e6 100644
--- a/ctdb/common/ctdb_daemon.c
+++ b/ctdb/common/ctdb_daemon.c
@@ -130,10 +130,10 @@ static struct ctdb_call_state *ctdb_daemon_fetch_lock_send(struct ctdb_db_contex
TDB_DATA *data)
{
struct ctdb_call *call;
- struct ctdb_record_handle *rec;
+ struct ctdb_fetch_handle *rec;
struct ctdb_call_state *state;
- rec = talloc(mem_ctx, struct ctdb_record_handle);
+ rec = talloc(mem_ctx, struct ctdb_fetch_handle);
CTDB_NO_MEMORY_NULL(ctdb_db->ctdb, rec);
@@ -150,6 +150,7 @@ static struct ctdb_call_state *ctdb_daemon_fetch_lock_send(struct ctdb_db_contex
state = ctdb_daemon_call_send_remote(ctdb_db, call, header);
state->fetch_private = rec;
+ talloc_steal(state, rec);
return state;
}
@@ -187,6 +188,7 @@ static void daemon_fetch_lock_complete(struct ctdb_call_state *state)
DEBUG(0,(__location__ " Failed to queue packet from daemon to client\n"));
}
talloc_free(r);
+ talloc_free(state);
}
/*
@@ -370,6 +372,14 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
static void daemon_incoming_packet(struct ctdb_client *client, void *data, size_t nread)
{
struct ctdb_req_header *hdr = data;
+ TALLOC_CTX *tmp_ctx;
+
+ /* place the packet as a child of a tmp_ctx. We then use
+ talloc_free() below to free it. If any of the calls want
+ to keep it, then they will steal it somewhere else, and the
+ talloc_free() will be a no-op */
+ tmp_ctx = talloc_new(client);
+ talloc_steal(tmp_ctx, hdr);
if (hdr->ctdb_magic != CTDB_MAGIC) {
ctdb_set_error(client->ctdb, "Non CTDB packet rejected in daemon\n");
@@ -406,7 +416,7 @@ static void daemon_incoming_packet(struct ctdb_client *client, void *data, size_
}
done:
- talloc_free(data);
+ talloc_free(tmp_ctx);
}