]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
af_unix: make sure to keep useful errno
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 4 Mar 2013 16:47:58 +0000 (10:47 -0600)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 4 Mar 2013 20:27:18 +0000 (14:27 -0600)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/af_unix.c

index 2a3482847bc7ad915531183ef2af5c89b03e152a..f6c65fb3aa80996043e59675bc8fe2d2b663eb8a 100644 (file)
@@ -56,12 +56,16 @@ int lxc_af_unix_open(const char *path, int type, int flags)
               path[0]?strlen(path):sizeof(addr.sun_path));
 
        if (bind(fd, (struct sockaddr *)&addr, sizeof(addr))) {
+               int tmp = errno;
                close(fd);
+               errno = tmp;
                return -1;
        }
        
        if (type == SOCK_STREAM && listen(fd, 100)) {
+               int tmp = errno;
                close(fd);
+               errno = tmp;
                return -1;
        }
 
@@ -99,7 +103,9 @@ int lxc_af_unix_connect(const char *path)
               path[0]?strlen(path):sizeof(addr.sun_path));
 
        if (connect(fd, (struct sockaddr *)&addr, sizeof(addr))) {
+               int tmp = errno;
                close(fd);
+               errno = tmp;
                return -1;
        }