diff options
| author | Anoop C S <anoopcs@redhat.com> | 2017-07-13 02:43:47 +0200 |
|---|---|---|
| committer | Michael Adam <obnox@samba.org> | 2017-07-27 14:16:31 +0200 |
| commit | e961a1c8b8e03d9e8f070a686207740b486340ea (patch) | |
| tree | 158c7837bf75ebcd02de7718953945f7373d1f0a /src | |
| parent | 070d84d733369a4de8f2b840a1f92065e2f3473d (diff) | |
| download | socket_wrapper-e961a1c8b8e03d9e8f070a686207740b486340ea.tar.gz socket_wrapper-e961a1c8b8e03d9e8f070a686207740b486340ea.tar.xz socket_wrapper-e961a1c8b8e03d9e8f070a686207740b486340ea.zip | |
swrap: Add common exit point to swrap_setsockopt
In preparation of thread safety.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/socket_wrapper.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 21e2fc1..46fb683 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -3954,6 +3954,7 @@ static int swrap_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) { struct socket_info *si = find_socket_info(s); + int ret; if (!si) { return libc_setsockopt(s, @@ -3982,17 +3983,20 @@ static int swrap_setsockopt(int s, int level, int optname, if (optval == NULL || optlen == 0 || optlen < (socklen_t)sizeof(int)) { errno = EINVAL; - return -1; + ret = -1; + goto done; } i = *discard_const_p(int, optval); if (i != 0 && i != 1) { errno = EINVAL; - return -1; + ret = -1; + goto done; } si->tcp_nodelay = i; - return 0; + ret = 0; + goto done; } #endif /* TCP_NODELAY */ default: @@ -4009,7 +4013,8 @@ static int swrap_setsockopt(int s, int level, int optname, } #endif /* IP_PKTINFO */ } - return 0; + ret = 0; + goto done; #ifdef HAVE_IPV6 case AF_INET6: if (level == IPPROTO_IPV6) { @@ -4019,12 +4024,17 @@ static int swrap_setsockopt(int s, int level, int optname, } #endif /* IPV6_PKTINFO */ } - return 0; + ret = 0; + goto done; #endif default: errno = ENOPROTOOPT; - return -1; + ret = -1; + goto done; } + +done: + return ret; } int setsockopt(int s, int level, int optname, |
