diff options
author | Volker Lendecke <vl@samba.org> | 2019-07-25 11:39:19 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-08-06 21:49:28 +0000 |
commit | df1caf29fbb745927f94a26598ee8e01ba8d9807 (patch) | |
tree | 9778b1270bf217afe0b02d5ff27998aeee9269aa /source3/torture | |
parent | e049ef3e787d8e7939b70d67a167766e89a04083 (diff) | |
download | samba-df1caf29fbb745927f94a26598ee8e01ba8d9807.tar.gz |
torture3: Don't duplicate set_blocking()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/torture')
-rw-r--r-- | source3/torture/wbc_async.c | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/source3/torture/wbc_async.c b/source3/torture/wbc_async.c index e45c01c50a0..9560e3623bd 100644 --- a/source3/torture/wbc_async.c +++ b/source3/torture/wbc_async.c @@ -30,6 +30,7 @@ #include "nsswitch/winbind_struct_protocol.h" #include "nsswitch/libwbclient/wbclient.h" #include "wbc_async.h" +#include "lib/util/blocking.h" wbcErr map_wbc_err_from_errno(int error) { @@ -124,10 +125,7 @@ static int make_nonstd_fd(int fd) } /**************************************************************************** - Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available, - else - if SYSV use O_NDELAY - if BSD use FNDELAY + Set a fd into blocking/nonblocking mode. Set close on exec also. ****************************************************************************/ @@ -140,29 +138,11 @@ static int make_safe_fd(int fd) goto fail; } - /* Socket should be nonblocking. */ - -#ifdef O_NONBLOCK -#define FLAG_TO_SET O_NONBLOCK -#else -#ifdef SYSV -#define FLAG_TO_SET O_NDELAY -#else /* BSD */ -#define FLAG_TO_SET FNDELAY -#endif -#endif - - if ((flags = fcntl(new_fd, F_GETFL)) == -1) { + result = set_blocking(new_fd, false); + if (result == -1) { goto fail; } - flags |= FLAG_TO_SET; - if (fcntl(new_fd, F_SETFL, flags) == -1) { - goto fail; - } - -#undef FLAG_TO_SET - /* Socket should be closed on exec() */ #ifdef FD_CLOEXEC result = flags = fcntl(new_fd, F_GETFD, 0); |