forked from enlightenment/efl
Ecore con local: properly clean up fd on error.
This wasn't done correctly in the previous commit. First of all, the order of cleanup was wrong, the cleanup area should only be called if failures occurred after the fd allocation, not before. Also, fd should be reinitialised to -1 once we close the socket.
This commit is contained in:
parent
f05577c3ae
commit
d4bd7d7033
|
@ -366,16 +366,16 @@ start:
|
||||||
goto error_umask;
|
goto error_umask;
|
||||||
|
|
||||||
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0)
|
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0)
|
||||||
goto error_umask;
|
goto error_fd;
|
||||||
|
|
||||||
if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0)
|
if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0)
|
||||||
goto error_umask;
|
goto error_fd;
|
||||||
|
|
||||||
lin.l_onoff = 1;
|
lin.l_onoff = 1;
|
||||||
lin.l_linger = 0;
|
lin.l_linger = 0;
|
||||||
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
|
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, (const void *)&lin,
|
||||||
sizeof(struct linger)) < 0)
|
sizeof(struct linger)) < 0)
|
||||||
goto error_umask;
|
goto error_fd;
|
||||||
|
|
||||||
if (bind(svr->fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0)
|
if (bind(svr->fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0)
|
||||||
{
|
{
|
||||||
|
@ -391,13 +391,13 @@ start:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERR("Local socket '%s' removal failed: %s", buf, strerror(errno));
|
ERR("Local socket '%s' removal failed: %s", buf, strerror(errno));
|
||||||
goto error_umask;
|
goto error_fd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listen(svr->fd, 4096) < 0)
|
if (listen(svr->fd, 4096) < 0)
|
||||||
goto error_umask;
|
goto error_fd;
|
||||||
|
|
||||||
#ifdef HAVE_SYSTEMD
|
#ifdef HAVE_SYSTEMD
|
||||||
fd_ready:
|
fd_ready:
|
||||||
|
@ -415,10 +415,12 @@ fd_ready:
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
error_fd:
|
||||||
|
close(svr->fd);
|
||||||
|
svr->fd = -1;
|
||||||
error_umask:
|
error_umask:
|
||||||
umask(pmode);
|
umask(pmode);
|
||||||
error:
|
error:
|
||||||
close(svr->fd);
|
|
||||||
#endif /* HAVE_LOCAL_SOCKETS */
|
#endif /* HAVE_LOCAL_SOCKETS */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue