]> git.tue.mpg.de Git - paraslash.git/commitdiff
09_fix-errno-usage.diff
authorGerrit Renker <grenker@cscs.ch>
Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)
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.

net.c

diff --git a/net.c b/net.c
index d9b3a9defa8164e98be1dda341df3a62b1e4bf9b..aeeca20e41447d2f3912b3035e739219ff08c62d 100644 (file)
--- 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);