merge status code changes from samba4 ctdb
authorAndrew Tridgell <tridge@samba.org>
Mon, 29 Jan 2007 11:30:06 +0000 (22:30 +1100)
committerAndrew Tridgell <tridge@samba.org>
Mon, 29 Jan 2007 11:30:06 +0000 (22:30 +1100)
(This used to be ctdb commit 705a9f8e5238976aa5c8cd4a5371459650d8b553)

ctdb/common/ctdb_call.c
ctdb/include/ctdb.h
ctdb/include/ctdb_private.h

index 3949206a55a71f2863d028178b8845f0a009019f..0169baf906245a4823a32d8d9482116c4d1a0ed7 100644 (file)
@@ -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;
 }
index 8a2006f678df6cff425711211e810654dba63689..7eebcb83db8e04e6238042f8ce8679b2ebcfe706 100644 (file)
@@ -26,6 +26,7 @@ struct ctdb_call {
        TDB_DATA key;
        TDB_DATA call_data;
        TDB_DATA reply_data;
+       uint32_t status;
 };
 
 /*
@@ -37,6 +38,7 @@ struct ctdb_call_info {
        TDB_DATA *new_data;    /* optionally updated record data */
        TDB_DATA *call_data;   /* optionally passed from caller */
        TDB_DATA *reply_data;  /* optionally returned by function */
+       uint32_t status;       /* optional reply status - defaults to zero */
 };
 
 #define CTDB_ERR_INVALID 1
index db7da8fcaf66bef0a8905fd0997f0c397bc60901..977206f400cc781b1b830fa5fcfc0f5f446ddcd9 100644 (file)
@@ -162,6 +162,7 @@ struct ctdb_req_call {
 
 struct ctdb_reply_call {
        struct ctdb_req_header hdr;
+       uint32_t status;
        uint32_t datalen;
        uint8_t  data[1];
 };