]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
tube replacement socketpair
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 5 Jul 2010 15:55:35 +0000 (15:55 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 5 Jul 2010 15:55:35 +0000 (15:55 +0000)
git-svn-id: file:///svn/unbound/trunk@2181 be551aaa-1e26-0410-a405-d3ace91eadb9

util/tube.c

index 3befc694552d4b97ebb040950c4ae98e232396ba..27af15a55c285568c8ed243de3bb107450d43b14 100644 (file)
@@ -51,7 +51,7 @@
 #ifndef HAVE_SOCKETPAIR
 /** define socketpair to another name in case it sneakily exists somehow */
 #define socketpair socketpair_compat
-static int socketpair(int ATTR_UNUSED(f), int ATTR_UNUSED(t),
+static int socketpair(int ATTR_UNUSED(f), int ATTR_UNUSED(tp),
        int ATTR_UNUSED(p), int sv[2])
 {
        /* no socketpair() available, like on Minix 3.1.7,
@@ -60,7 +60,8 @@ static int socketpair(int ATTR_UNUSED(f), int ATTR_UNUSED(t),
        socklen_t len;
        int s, t;
        /* hope this port is not in use ... */
-       static int the_port = 1025 + (getpid() % 16384);
+       static int the_port = 0;
+       if(the_port == 0) the_port = 1025 + (getpid() % 16384);
        s = socket(AF_INET, SOCK_STREAM, 0);
        if(s == -1) {
                log_err("socket: %s", strerror(errno));
@@ -73,7 +74,7 @@ static int socketpair(int ATTR_UNUSED(f), int ATTR_UNUSED(t),
                return -1;
        }
        ((struct sockaddr_in*)&addr)->sin_port = htons(the_port++);
-       if(bind(s, &addr, len) == -1) {
+       if(bind(s, (struct sockaddr*)&addr, len) == -1) {
                log_err("bind: %s", strerror(errno));
                close(s);
                return -1;
@@ -91,7 +92,7 @@ static int socketpair(int ATTR_UNUSED(f), int ATTR_UNUSED(t),
                close(s);
                return -1;
        }
-       if(connect(t, &addr, len) == -1) {
+       if(connect(t, (struct sockaddr*)&addr, len) == -1) {
                log_err("connect: %s", strerror(errno));
                close(s);
                close(t);
@@ -99,7 +100,7 @@ static int socketpair(int ATTR_UNUSED(f), int ATTR_UNUSED(t),
        }
 
        len = (socklen_t)sizeof(addr);
-       sv[0] = accept(s, &addr, &len, 0);
+       sv[0] = accept(s, (struct sockaddr*)&addr, &len);
        if(sv[0] == -1) {
                log_err("accept: %s", strerror(errno));
                close(s);
@@ -107,7 +108,7 @@ static int socketpair(int ATTR_UNUSED(f), int ATTR_UNUSED(t),
                return -1;
        }
        sv[1] = t;
-       close(s)
+       close(s);
        return 0;
 }
 #endif /* HAVE_SOCKETPAIR */