Pass TFD_NONBLOCK to timerfd_create to avoid later fcntl
authorKyle Evans <kevans@FreeBSD.org>
Thu, 3 May 2018 02:03:49 +0000 (21:03 -0500)
committerKyle Evans <kevans@FreeBSD.org>
Thu, 3 May 2018 02:03:49 +0000 (21:03 -0500)
winpr/libwinpr/synch/timer.c

index dbd628f..4adfdac 100644 (file)
@@ -235,22 +235,13 @@ static int InitializeWaitableTimer(WINPR_TIMER* timer)
        {
 #ifdef HAVE_SYS_TIMERFD_H
                int status;
-               timer->fd = timerfd_create(CLOCK_MONOTONIC, 0);
+               timer->fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
 
                if (timer->fd <= 0)
                {
                        free(timer);
                        return -1;
                }
-
-               status = fcntl(timer->fd, F_SETFL, O_NONBLOCK);
-
-               if (status)
-               {
-                       close(timer->fd);
-                       return -1;
-               }
-
 #elif defined(__APPLE__)
 #else
                WLog_ERR(TAG, "%s: os specific implementation is missing", __FUNCTION__);