From: Gerrit Renker Date: Thu, 25 Feb 2010 16:05:45 +0000 (+0100) Subject: 09_fix-errno-usage.diff X-Git-Tag: v0.4.2~36 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=818d1a3aa98121ec2d5339d11dece7bc2f5aa6af;p=paraslash.git 09_fix-errno-usage.diff This fixes a bug in the use of errno which corresponds to the 'common mistake' in the use of errno(3): to not save it before making new system calls. Thanks. --- diff --git a/net.c b/net.c index d9b3a9de..aeeca20e 100644 --- a/net.c +++ b/net.c @@ -457,10 +457,11 @@ get_next_src: flowopt_cleanup(fo); if (src == NULL && dst == NULL) { + rc = errno; 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(errno); + return -ERRNO_TO_PARA_ERROR(rc); } return sockfd; } @@ -491,8 +492,9 @@ int para_listen(unsigned l4type, uint16_t port, struct flowopts *fo) if (fd > 0) { ret = listen(fd, BACKLOG); if (ret < 0) { + ret = errno; close(fd); - return -ERRNO_TO_PARA_ERROR(errno); + return -ERRNO_TO_PARA_ERROR(ret); } PARA_INFO_LOG("listening on %s port %u, fd %d\n", layer4_name(l4type), port, fd);