diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-01-23 11:38:45 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2007-01-23 11:38:45 +1100 |
commit | 16d2ca6fa0c2e431240b2033d0b2c9196e66c200 (patch) | |
tree | 01c42ea4612ef2faad7ae039ae0705eb6d55cdcf /ctdb/tcp | |
parent | 0d9ec11a5099c00603d9e97901cc14653179f40f (diff) | |
download | samba-16d2ca6fa0c2e431240b2033d0b2c9196e66c200.tar.gz samba-16d2ca6fa0c2e431240b2033d0b2c9196e66c200.tar.xz samba-16d2ca6fa0c2e431240b2033d0b2c9196e66c200.zip |
merge fixes from samba4
(This used to be ctdb commit fb90a5424348d0b6ed9a1b8da4ceadcc4d1a1cb1)
Diffstat (limited to 'ctdb/tcp')
-rw-r--r-- | ctdb/tcp/tcp_connect.c | 5 | ||||
-rw-r--r-- | ctdb/tcp/tcp_init.c | 3 | ||||
-rw-r--r-- | ctdb/tcp/tcp_io.c | 23 |
3 files changed, 20 insertions, 11 deletions
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c index 12dfc57d87..e828bb7cbb 100644 --- a/ctdb/tcp/tcp_connect.c +++ b/ctdb/tcp/tcp_connect.c @@ -20,9 +20,10 @@ #include "includes.h" #include "lib/events/events.h" +#include "lib/tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" -#include "ctdb_private.h" +#include "../include/ctdb_private.h" #include "ctdb_tcp.h" static void set_nonblocking(int fd) @@ -88,7 +89,7 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, sock_out.sin_port = htons(node->address.port); sock_out.sin_family = PF_INET; - if (connect(tnode->fd, &sock_out, sizeof(sock_out)) != 0 && + if (connect(tnode->fd, (struct sockaddr *)&sock_out, sizeof(sock_out)) != 0 && errno != EINPROGRESS) { /* try again once a second */ close(tnode->fd); diff --git a/ctdb/tcp/tcp_init.c b/ctdb/tcp/tcp_init.c index f261d0c7da..0058e7ad85 100644 --- a/ctdb/tcp/tcp_init.c +++ b/ctdb/tcp/tcp_init.c @@ -19,10 +19,11 @@ */ #include "includes.h" +#include "lib/tdb/include/tdb.h" #include "lib/events/events.h" #include "system/network.h" #include "system/filesys.h" -#include "ctdb_private.h" +#include "../include/ctdb_private.h" #include "ctdb_tcp.h" /* diff --git a/ctdb/tcp/tcp_io.c b/ctdb/tcp/tcp_io.c index 63142f9c45..5385ad7f46 100644 --- a/ctdb/tcp/tcp_io.c +++ b/ctdb/tcp/tcp_io.c @@ -20,9 +20,11 @@ #include "includes.h" #include "lib/events/events.h" +#include "lib/util/dlinklist.h" +#include "lib/tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" -#include "ctdb_private.h" +#include "../include/ctdb_private.h" #include "ctdb_tcp.h" @@ -199,15 +201,20 @@ int ctdb_tcp_queue_pkt(struct ctdb_node *node, uint8_t *data, uint32_t length) struct ctdb_tcp_node *tnode = talloc_get_type(node->private, struct ctdb_tcp_node); struct ctdb_tcp_packet *pkt; + uint32_t length2; /* 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; + length2 = (length+(CTDB_TCP_ALIGNMENT-1)) & ~(CTDB_TCP_ALIGNMENT-1); + *(uint32_t *)data = length2; + + if (length2 != length) { + memset(data+length, 0, length2-length); + } /* if the queue is empty then try an immediate write, avoiding queue overhead. This relies on non-blocking sockets */ if (tnode->queue == NULL && tnode->fd != -1) { - ssize_t n = write(tnode->fd, data, length); + ssize_t n = write(tnode->fd, data, length2); if (n == -1 && errno != EAGAIN && errno != EWOULDBLOCK) { event_add_timed(node->ctdb->ev, node, timeval_zero(), ctdb_tcp_node_dead, node); @@ -217,18 +224,18 @@ int ctdb_tcp_queue_pkt(struct ctdb_node *node, uint8_t *data, uint32_t length) } if (n > 0) { data += n; - length -= n; + length2 -= n; } - if (length == 0) return 0; + if (length2 == 0) return 0; } pkt = talloc(tnode, struct ctdb_tcp_packet); CTDB_NO_MEMORY(node->ctdb, pkt); - pkt->data = talloc_memdup(pkt, data, length); + pkt->data = talloc_memdup(pkt, data, length2); CTDB_NO_MEMORY(node->ctdb, pkt->data); - pkt->length = length; + pkt->length = length2; if (tnode->queue == NULL && tnode->fd != -1) { EVENT_FD_WRITEABLE(tnode->fde); |