X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=net.c;h=ffd4350b4b14bc32d8e270db2734cc97fee400df;hp=32f3ffe943d33d7ffca4f002e2d2c1c4a52841da;hb=a24d175e6d093d6d9f6e583c3026e45924bad621;hpb=8c488022fea5ba573534585cb7b123836144c6c2 diff --git a/net.c b/net.c index 32f3ffe9..ffd4350b 100644 --- a/net.c +++ b/net.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Andre Noll + * Copyright (C) 2005-2011 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -25,13 +25,10 @@ #define AI_ADDRCONFIG 0 #endif -#include #include -#include #include "para.h" #include "error.h" -#include "crypt.h" #include "net.h" #include "string.h" #include "list.h" @@ -380,8 +377,8 @@ int makesock(unsigned l4type, bool passive, const char *host, uint16_t port_number, struct flowopts *fo) { - struct addrinfo *local = NULL, *src, - *remote = NULL, *dst, hints; + struct addrinfo *local = NULL, *src = NULL, *remote = NULL, + *dst = NULL, hints; unsigned int l3type = AF_UNSPEC; int rc, on = 1, sockfd = -1, socktype = sock_type(l4type); @@ -414,7 +411,8 @@ int makesock(unsigned l4type, bool passive, layer4_name(l4type), host? host : (passive? "[loopback]" : "[localhost]"), port, gai_strerror(rc)); - return -E_ADDRESS_LOOKUP; + rc = -E_ADDRESS_LOOKUP; + goto out; } /* Iterate over all src/dst combination, exhausting dst first */ @@ -439,7 +437,8 @@ int makesock(unsigned l4type, bool passive, close(sockfd); PARA_ERROR_LOG("can not set SO_REUSEADDR: %s\n", strerror(rc)); - return -ERRNO_TO_PARA_ERROR(rc); + rc = -ERRNO_TO_PARA_ERROR(rc); + break; } flowopt_setopts(sockfd, fo); @@ -462,6 +461,7 @@ get_next_src: if (src && (src = src->ai_next)) /* restart inner loop */ dst = remote; } +out: if (local) freeaddrinfo(local); if (remote) @@ -469,11 +469,12 @@ get_next_src: flowopt_cleanup(fo); if (src == NULL && dst == NULL) { - rc = errno; + if (rc >= 0) + rc = -E_MAKESOCK; PARA_ERROR_LOG("can not create %s socket %s#%s.\n", layer4_name(l4type), host? host : (passive? "[loopback]" : "[localhost]"), port); - return -ERRNO_TO_PARA_ERROR(rc); + return rc; } return sockfd; } @@ -951,7 +952,7 @@ int connect_local_socket(const char *name) struct sockaddr_un unix_addr; int fd, ret; - PARA_INFO_LOG("connecting to %s\n", name); + PARA_DEBUG_LOG("connecting to %s\n", name); ret = init_unix_addr(&unix_addr, name); if (ret < 0) return ret;