Commit dba104c8 by Serge Hallyn

af_unix: make sure to keep useful errno

parent 65a2d6b2
...@@ -56,12 +56,16 @@ int lxc_af_unix_open(const char *path, int type, int flags) ...@@ -56,12 +56,16 @@ int lxc_af_unix_open(const char *path, int type, int flags)
path[0]?strlen(path):sizeof(addr.sun_path)); path[0]?strlen(path):sizeof(addr.sun_path));
if (bind(fd, (struct sockaddr *)&addr, sizeof(addr))) { if (bind(fd, (struct sockaddr *)&addr, sizeof(addr))) {
int tmp = errno;
close(fd); close(fd);
errno = tmp;
return -1; return -1;
} }
if (type == SOCK_STREAM && listen(fd, 100)) { if (type == SOCK_STREAM && listen(fd, 100)) {
int tmp = errno;
close(fd); close(fd);
errno = tmp;
return -1; return -1;
} }
...@@ -99,7 +103,9 @@ int lxc_af_unix_connect(const char *path) ...@@ -99,7 +103,9 @@ int lxc_af_unix_connect(const char *path)
path[0]?strlen(path):sizeof(addr.sun_path)); path[0]?strlen(path):sizeof(addr.sun_path));
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr))) { if (connect(fd, (struct sockaddr *)&addr, sizeof(addr))) {
int tmp = errno;
close(fd); close(fd);
errno = tmp;
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment