utils: Add convenience function for setting fd flags

There are many places in the code base where we ignore the return value
of fcntl() when getting/setting file descriptior flags. This patch
introduces a convenience function that allows setting or clearing file
descriptor flags and will also log an error on failure for later
analysis.

Change-Id: I8b81901e1b1bd537ca632567cdb408931c6eded7
This commit is contained in:
Sean Bright
2017-12-07 10:52:39 -05:00
parent 54a86779a3
commit f726f11974
19 changed files with 103 additions and 104 deletions

View File

@@ -132,9 +132,7 @@ static void *pthread_timer_open(void)
}
for (i = 0; i < ARRAY_LEN(timer->pipe); ++i) {
int flags = fcntl(timer->pipe[i], F_GETFL);
flags |= O_NONBLOCK;
fcntl(timer->pipe[i], F_SETFL, flags);
ast_fd_set_flags(timer->pipe[i], O_NONBLOCK);
}
ao2_lock(pthread_timers);