From: Volker Lendecke Date: Thu, 25 Jul 2019 09:39:19 +0000 (+0200) Subject: torture3: Don't duplicate set_blocking() X-Git-Tag: tdb-1.4.2~304 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=df1caf29fbb745927f94a26598ee8e01ba8d9807;p=thirdparty%2Fsamba.git torture3: Don't duplicate set_blocking() Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- 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);