diff options
author | Peter Wemm <peter@FreeBSD.org> | 2015-08-09 04:32:54 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2015-08-09 04:32:54 +0000 |
commit | df84d2567179e9d8867957c089683d753016bd75 (patch) | |
tree | 22f2e9932cfc8bcfa6f728a311818f18a1f1d80d /network_io/unix/sockets.c | |
parent | bc9ddba9ef9abe23eadcdb51b2ce814c00c00639 (diff) |
Diffstat (limited to 'network_io/unix/sockets.c')
-rw-r--r-- | network_io/unix/sockets.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/network_io/unix/sockets.c b/network_io/unix/sockets.c index 514edb1a499a6..b95794f183add 100644 --- a/network_io/unix/sockets.c +++ b/network_io/unix/sockets.c @@ -145,13 +145,22 @@ apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, #ifndef HAVE_SOCK_CLOEXEC { int flags; + apr_status_t rv; - if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) - return errno; + if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) { + rv = errno; + close((*new)->socketdes); + (*new)->socketdes = -1; + return rv; + } flags |= FD_CLOEXEC; - if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) - return errno; + if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) { + rv = errno; + close((*new)->socketdes); + (*new)->socketdes = -1; + return rv; + } } #endif @@ -306,13 +315,22 @@ apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock, #ifndef HAVE_ACCEPT4 { int flags; + apr_status_t rv; - if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) - return errno; + if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) { + rv = errno; + close((*new)->socketdes); + (*new)->socketdes = -1; + return rv; + } flags |= FD_CLOEXEC; - if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) - return errno; + if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) { + rv = errno; + close((*new)->socketdes); + (*new)->socketdes = -1; + return rv; + } } #endif |