AIX needs sin_len field for bind()
authorAndrew Tridgell <tridge@samba.org>
Mon, 14 May 2007 23:42:52 +0000 (09:42 +1000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 14 May 2007 23:42:52 +0000 (09:42 +1000)
configure.ac
tcp/tcp_connect.c

index dd379b98cc67d4030df8548d181df8304e32b358..e6930a680252cc7f1683f6f7859c6eb119fc020e 100644 (file)
@@ -30,6 +30,16 @@ m4_include(libtdb.m4)
 m4_include(libevents.m4)
 m4_include(ib/config.m4)
 
+AC_CACHE_CHECK([for sin_len in sock],ctdb_cv_HAVE_SOCK_SIN_LEN,[
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>],
+[struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
+ctdb_cv_HAVE_SOCK_SIN_LEN=yes,ctdb_cv_HAVE_SOCK_SIN_LEN=no)])
+if test x"$ctdb_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
+    AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
+fi
+
 AC_SUBST(EXTRA_OBJ)
 
 AC_OUTPUT(Makefile)
index d5c943bc42fa9f0e88dc4e61895e89679aa91c66..ac82e4f5757169086c8a8748dacc47981b5b5574 100644 (file)
@@ -125,6 +125,10 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te,
 
        set_nonblocking(tnode->fd);
 
+       ZERO_STRUCT(sock_out);
+#ifdef HAVE_SOCK_SIN_LEN
+       sock_out.sin_len = sizeof(sock_out);
+#endif
        if (ctdb_tcp_get_address(ctdb, node->address.address, &sock_out.sin_addr) != 0) {
                return;
        }
@@ -138,6 +142,10 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te,
         * the remote side is actually routable in case CTDB traffic will run on
         * a dedicated non-routeable network.
         */
+       ZERO_STRUCT(sock_in);
+#ifdef HAVE_SOCK_SIN_LEN
+       sock_in.sin_len = sizeof(sock_in);
+#endif
        if (ctdb_tcp_get_address(ctdb, ctdb->address.address, &sock_in.sin_addr) != 0) {
                return;
        }
@@ -239,6 +247,10 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
        }
 
        for (i=0;i<ctdb->num_nodes;i++) {
+               ZERO_STRUCT(sock);
+#ifdef HAVE_SOCK_SIN_LEN
+               sock.sin_len = sizeof(sock);
+#endif
                sock.sin_port = htons(ctdb->nodes[i]->address.port);
                sock.sin_family = PF_INET;
                if (ctdb_tcp_get_address(ctdb, ctdb->nodes[i]->address.address, 
@@ -309,6 +321,10 @@ int ctdb_tcp_listen(struct ctdb_context *ctdb)
                return ctdb_tcp_listen_automatic(ctdb);
        }
 
+       ZERO_STRUCT(sock);
+#ifdef HAVE_SOCK_SIN_LEN
+       sock.sin_len = sizeof(sock);
+#endif
        sock.sin_port = htons(ctdb->address.port);
        sock.sin_family = PF_INET;