]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
torture3: Don't duplicate set_blocking()
authorVolker Lendecke <vl@samba.org>
Thu, 25 Jul 2019 09:39:19 +0000 (11:39 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 6 Aug 2019 21:49:28 +0000 (21:49 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/torture/wbc_async.c

index e45c01c50a0afa1bb1d535be747bb18182e3080e..9560e3623bd5984c876ba08cf62df8c54c001a0c 100644 (file)
@@ -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);