ctdb-server: Cleanup ctdb_daemon_call_send_remote
authorSwen Schillig <swen@vnet.ibm.com>
Thu, 8 Feb 2018 10:33:08 +0000 (11:33 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 30 Mar 2018 22:07:18 +0000 (00:07 +0200)
Minor code cleanup and adding a temporary variable to improve readabilty.

Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
ctdb/server/ctdb_call.c

index 17d6f98..836d615 100644 (file)
@@ -1464,6 +1464,7 @@ struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctd
        uint32_t len;
        struct ctdb_call_state *state;
        struct ctdb_context *ctdb = ctdb_db->ctdb;
+       struct ctdb_req_call_old *c;
 
        if (ctdb->methods == NULL) {
                DEBUG(DEBUG_INFO,(__location__ " Failed send packet. Transport is down\n"));
@@ -1479,31 +1480,40 @@ struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctd
        state->ctdb_db = ctdb_db;
        talloc_set_destructor(state, ctdb_call_destructor);
 
-       len = offsetof(struct ctdb_req_call_old, data) + call->key.dsize + call->call_data.dsize;
-       state->c = ctdb_transport_allocate(ctdb, state, CTDB_REQ_CALL, len, 
-                                          struct ctdb_req_call_old);
-       CTDB_NO_MEMORY_NULL(ctdb, state->c);
-       state->c->hdr.destnode  = header->dmaster;
-
-       /* this limits us to 16k outstanding messages - not unreasonable */
-       state->c->hdr.reqid     = state->reqid;
-       state->c->hdr.generation = ctdb_db->generation;
-       state->c->flags         = call->flags;
-       state->c->db_id         = ctdb_db->db_id;
-       state->c->callid        = call->call_id;
-       state->c->hopcount      = 0;
-       state->c->keylen        = call->key.dsize;
-       state->c->calldatalen   = call->call_data.dsize;
-       memcpy(&state->c->data[0], call->key.dptr, call->key.dsize);
-       memcpy(&state->c->data[call->key.dsize], 
-              call->call_data.dptr, call->call_data.dsize);
-       *(state->call)              = *call;
-       state->call->call_data.dptr = &state->c->data[call->key.dsize];
-       state->call->key.dptr       = &state->c->data[0];
-
        state->state  = CTDB_CALL_WAIT;
        state->generation = ctdb_db->generation;
 
+       len = offsetof(struct ctdb_req_call_old, data) + call->key.dsize +
+                      call->call_data.dsize;
+
+       c = ctdb_transport_allocate(ctdb,
+                                   state,
+                                   CTDB_REQ_CALL,
+                                   len,
+                                   struct ctdb_req_call_old);
+
+       CTDB_NO_MEMORY_NULL(ctdb, c);
+       state->c = c;
+
+       c->hdr.destnode  = header->dmaster;
+       c->hdr.reqid     = state->reqid;
+       c->hdr.generation = ctdb_db->generation;
+       c->flags         = call->flags;
+       c->db_id         = ctdb_db->db_id;
+       c->callid        = call->call_id;
+       c->hopcount      = 0;
+       c->keylen        = call->key.dsize;
+       c->calldatalen   = call->call_data.dsize;
+
+       memcpy(&c->data[0], call->key.dptr, call->key.dsize);
+       memcpy(&c->data[call->key.dsize],
+              call->call_data.dptr,
+              call->call_data.dsize);
+
+       *(state->call) = *call;
+       state->call->call_data.dptr = &c->data[call->key.dsize];
+       state->call->key.dptr       = &c->data[0];
+
        DLIST_ADD(ctdb_db->pending_calls, state);
 
        ctdb_queue_packet(ctdb, &state->c->hdr);