diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-01-29 11:31:24 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:44:25 -0500 |
commit | ef219698199883858a528b11148fe7c00c02b860 (patch) | |
tree | c0776768da8f880e1808fd2cd27b472fb9d83ada /source4/cluster/ctdb/common | |
parent | e46d128bb598dd8b460c8f6ad0236748f9da47bb (diff) | |
download | samba-ef219698199883858a528b11148fe7c00c02b860.tar.gz samba-ef219698199883858a528b11148fe7c00c02b860.tar.bz2 samba-ef219698199883858a528b11148fe7c00c02b860.zip |
r21045: every call in brlock_ctdb ended up neededing a 32 bit status code, so
rather than allocating a reply_data field each time, I have changed
the ctdb_call API to include a status code. That greatly simplifies
use of the API.
(This used to be commit 70c3acaf8876fa5712e2135df234fe3bc1e32e77)
Diffstat (limited to 'source4/cluster/ctdb/common')
-rw-r--r-- | source4/cluster/ctdb/common/ctdb_call.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/source4/cluster/ctdb/common/ctdb_call.c b/source4/cluster/ctdb/common/ctdb_call.c index 3949206a55..0169baf906 100644 --- a/source4/cluster/ctdb/common/ctdb_call.c +++ b/source4/cluster/ctdb/common/ctdb_call.c @@ -61,6 +61,7 @@ static int ctdb_call_local(struct ctdb_context *ctdb, struct ctdb_call *call, CTDB_NO_MEMORY(ctdb, c->record_data.dptr); c->new_data = NULL; c->reply_data = NULL; + c->status = 0; for (fn=ctdb->calls;fn;fn=fn->next) { if (fn->id == call->call_id) break; @@ -101,6 +102,7 @@ static int ctdb_call_local(struct ctdb_context *ctdb, struct ctdb_call *call, call->reply_data.dptr = NULL; call->reply_data.dsize = 0; } + call->status = c->status; talloc_free(c); @@ -333,12 +335,15 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) r->hdr.destnode = hdr->srcnode; r->hdr.srcnode = hdr->destnode; r->hdr.reqid = hdr->reqid; + r->status = call.status; r->datalen = call.reply_data.dsize; - memcpy(&r->data[0], call.reply_data.dptr, call.reply_data.dsize); + if (call.reply_data.dsize) { + memcpy(&r->data[0], call.reply_data.dptr, call.reply_data.dsize); + talloc_free(call.reply_data.dptr); + } ctdb_queue_packet(ctdb, &r->hdr); - talloc_free(call.reply_data.dptr); talloc_free(r); } @@ -368,15 +373,13 @@ void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) { struct ctdb_reply_call *c = (struct ctdb_reply_call *)hdr; struct ctdb_call_state *state; - TDB_DATA reply_data; state = idr_find(ctdb->idr, hdr->reqid); if (state == NULL) return; - reply_data.dptr = c->data; - reply_data.dsize = c->datalen; - - state->call.reply_data = reply_data; + state->call.reply_data.dptr = c->data; + state->call.reply_data.dsize = c->datalen; + state->call.status = c->status; talloc_steal(state, c); @@ -594,10 +597,16 @@ int ctdb_call_recv(struct ctdb_call_state *state, struct ctdb_call *call) talloc_free(state); return -1; } - call->reply_data.dptr = talloc_memdup(state->node->ctdb, - state->call.reply_data.dptr, - state->call.reply_data.dsize); - call->reply_data.dsize = state->call.reply_data.dsize; + if (state->call.reply_data.dsize) { + call->reply_data.dptr = talloc_memdup(state->node->ctdb, + state->call.reply_data.dptr, + state->call.reply_data.dsize); + call->reply_data.dsize = state->call.reply_data.dsize; + } else { + call->reply_data.dptr = NULL; + call->reply_data.dsize = 0; + } + call->status = state->call.status; talloc_free(state); return 0; } |