------------------------------------------------------------
revno: 205
revision-id: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: Andrew Tridgell <[EMAIL PROTECTED]>
branch nick: tridge
timestamp: Fri 2007-04-27 17:10:47 +0200
message:
  always use allocated packets to avoid alignment errors
modified:
  common/ctdb_client.c           ctdb_client.c-20070411010216-3kd8v37k61steeya-1
  common/ctdb_daemon.c           ctdb_daemon.c-20070409200331-3el1kqgdb9m4ib0g-1
=== modified file 'common/ctdb_client.c'
--- a/common/ctdb_client.c      2007-04-27 14:31:45 +0000
+++ b/common/ctdb_client.c      2007-04-27 15:10:47 +0000
@@ -381,7 +381,7 @@
                             void *private_data)
                                    
 {
-       struct ctdb_req_register c;
+       struct ctdb_req_register *c;
        int res;
 
        /* if the domain socket is not yet open, open it */
@@ -389,15 +389,15 @@
                ctdb_socket_connect(ctdb);
        }
 
-       ZERO_STRUCT(c);
-
-       c.hdr.length       = sizeof(c);
-       c.hdr.ctdb_magic   = CTDB_MAGIC;
-       c.hdr.ctdb_version = CTDB_VERSION;
-       c.hdr.operation    = CTDB_REQ_REGISTER;
-       c.srvid            = srvid;
-
-       res = ctdb_client_queue_pkt(ctdb, &c.hdr);
+       c = ctdbd_allocate_pkt(ctdb, sizeof(*c));
+       c->hdr.length       = sizeof(*c);
+       c->hdr.ctdb_magic   = CTDB_MAGIC;
+       c->hdr.ctdb_version = CTDB_VERSION;
+       c->hdr.operation    = CTDB_REQ_REGISTER;
+       c->srvid            = srvid;
+
+       res = ctdb_client_queue_pkt(ctdb, &c->hdr);
+       talloc_free(c);
        if (res != 0) {
                return res;
        }
@@ -446,15 +446,14 @@
  */
 void ctdb_connect_wait(struct ctdb_context *ctdb)
 {
-       struct ctdb_req_connect_wait r;
+       struct ctdb_req_connect_wait *r;
        int res;
 
-       ZERO_STRUCT(r);
-
-       r.hdr.length     = sizeof(r);
-       r.hdr.ctdb_magic = CTDB_MAGIC;
-       r.hdr.ctdb_version = CTDB_VERSION;
-       r.hdr.operation = CTDB_REQ_CONNECT_WAIT;
+       r = ctdbd_allocate_pkt(ctdb, sizeof(*r));
+       r->hdr.length     = sizeof(*r);
+       r->hdr.ctdb_magic = CTDB_MAGIC;
+       r->hdr.ctdb_version = CTDB_VERSION;
+       r->hdr.operation = CTDB_REQ_CONNECT_WAIT;
 
        DEBUG(3,("ctdb_connect_wait: sending to ctdbd\n"));
 
@@ -463,7 +462,8 @@
                ctdb_socket_connect(ctdb);
        }
        
-       res = ctdb_queue_send(ctdb->daemon.queue, (uint8_t *)&r.hdr, 
r.hdr.length);
+       res = ctdb_queue_send(ctdb->daemon.queue, (uint8_t *)&r->hdr, 
r->hdr.length);
+       talloc_free(r);
        if (res != 0) {
                DEBUG(0,(__location__ " Failed to queue a connect wait 
request\n"));
                return;
@@ -596,23 +596,24 @@
 */
 void ctdb_shutdown(struct ctdb_context *ctdb)
 {
-       struct ctdb_req_shutdown r;
-       int len;
+       struct ctdb_req_shutdown *r;
 
        /* if the domain socket is not yet open, open it */
        if (ctdb->daemon.sd==-1) {
                ctdb_socket_connect(ctdb);
        }
 
-       len = sizeof(struct ctdb_req_shutdown);
-       ZERO_STRUCT(r);
-       r.hdr.length       = len;
-       r.hdr.ctdb_magic   = CTDB_MAGIC;
-       r.hdr.ctdb_version = CTDB_VERSION;
-       r.hdr.operation    = CTDB_REQ_SHUTDOWN;
-       r.hdr.reqid        = 0;
-
-       ctdb_client_queue_pkt(ctdb, &(r.hdr));
+       r = ctdbd_allocate_pkt(ctdb, sizeof(*r));
+       ZERO_STRUCT(*r);
+       r->hdr.length       = sizeof(*r);
+       r->hdr.ctdb_magic   = CTDB_MAGIC;
+       r->hdr.ctdb_version = CTDB_VERSION;
+       r->hdr.operation    = CTDB_REQ_SHUTDOWN;
+       r->hdr.reqid        = 0;
+
+       ctdb_client_queue_pkt(ctdb, &(r->hdr));
+
+       talloc_free(r);
 
        /* this event loop will terminate once we receive the reply */
        while (1) {

=== modified file 'common/ctdb_daemon.c'
--- a/common/ctdb_daemon.c      2007-04-27 14:31:45 +0000
+++ b/common/ctdb_daemon.c      2007-04-27 15:10:47 +0000
@@ -216,23 +216,23 @@
 static void daemon_request_connect_wait(struct ctdb_client *client, 
                                        struct ctdb_req_connect_wait *c)
 {
-       struct ctdb_reply_connect_wait r;
+       struct ctdb_reply_connect_wait *r;
        int res;
 
        /* first wait - in the daemon */
        ctdb_daemon_connect_wait(client->ctdb);
 
        /* now send the reply */
-       ZERO_STRUCT(r);
-
-       r.hdr.length     = sizeof(r);
-       r.hdr.ctdb_magic = CTDB_MAGIC;
-       r.hdr.ctdb_version = CTDB_VERSION;
-       r.hdr.operation = CTDB_REPLY_CONNECT_WAIT;
-       r.vnn           = ctdb_get_vnn(client->ctdb);
-       r.num_connected = client->ctdb->num_connected;
+       r = ctdbd_allocate_pkt(client, sizeof(*r));
+       r->hdr.length     = sizeof(*r);
+       r->hdr.ctdb_magic = CTDB_MAGIC;
+       r->hdr.ctdb_version = CTDB_VERSION;
+       r->hdr.operation = CTDB_REPLY_CONNECT_WAIT;
+       r->vnn           = ctdb_get_vnn(client->ctdb);
+       r->num_connected = client->ctdb->num_connected;
        
-       res = daemon_queue_send(client, &r.hdr);
+       res = daemon_queue_send(client, &r->hdr);
+       talloc_free(r);
        if (res != 0) {
                DEBUG(0,(__location__ " Failed to queue a connect wait 
response\n"));
                return;

Reply via email to