------------------------------------------------------------
revno: 41
revision-id: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: Andrew Tridgell <[EMAIL PROTECTED]>
branch nick: tridge
timestamp: Tue 2006-12-19 12:07:07 +1100
message:
  enforce the tcp memory alignment in packet queue 
modified:
  tcp/ctdb_tcp.h                 ctdb_tcp.h-20061127103747-l8xeniwiapbydehq-3
  tcp/tcp_init.c                 tcp_init.c-20061128004937-x70q1cu5xzg5g2tm-2
  tcp/tcp_io.c                   tcp_io.c-20061128004937-x70q1cu5xzg5g2tm-3
=== modified file 'tcp/ctdb_tcp.h'
--- a/tcp/ctdb_tcp.h    2006-12-19 01:03:10 +0000
+++ b/tcp/ctdb_tcp.h    2006-12-19 01:07:07 +0000
@@ -72,3 +72,5 @@
 int ctdb_tcp_listen(struct ctdb_context *ctdb);
 void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, 
                           struct timeval t, void *private);
+
+#define CTDB_TCP_ALIGNMENT 8

=== modified file 'tcp/tcp_init.c'
--- a/tcp/tcp_init.c    2006-12-19 01:03:10 +0000
+++ b/tcp/tcp_init.c    2006-12-19 01:07:07 +0000
@@ -72,7 +72,7 @@
        /* tcp transport needs to round to 8 byte alignment to ensure
           that we can use a length header and 64 bit elements in
           structures */
-       size = (size+7) & ~7;
+       size = (size+(CTDB_TCP_ALIGNMENT-1)) & ~(CTDB_TCP_ALIGNMENT-1);
        return talloc_size(ctdb, size);
 }
 

=== modified file 'tcp/tcp_io.c'
--- a/tcp/tcp_io.c      2006-12-19 01:03:10 +0000
+++ b/tcp/tcp_io.c      2006-12-19 01:07:07 +0000
@@ -199,6 +199,10 @@
        struct ctdb_tcp_node *tnode = talloc_get_type(node->private, 
                                                      struct ctdb_tcp_node);
        struct ctdb_tcp_packet *pkt;
+
+       /* enforce the length and alignment rules from the tcp packet allocator 
*/
+       length = (length+(CTDB_TCP_ALIGNMENT-1)) & ~(CTDB_TCP_ALIGNMENT-1);
+       *(uint32_t *)data = length;
        
        /* if the queue is empty then try an immediate write, avoiding
           queue overhead. This relies on non-blocking sockets */

Reply via email to