mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
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:
@@ -1014,7 +1014,6 @@ struct ast_udptl *ast_udptl_new_with_bindaddr(struct ast_sched_context *sched, s
|
||||
int x;
|
||||
int startplace;
|
||||
int i;
|
||||
long int flags;
|
||||
RAII_VAR(struct udptl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
|
||||
|
||||
if (!cfg || !cfg->general) {
|
||||
@@ -1045,8 +1044,7 @@ struct ast_udptl *ast_udptl_new_with_bindaddr(struct ast_sched_context *sched, s
|
||||
ast_log(LOG_WARNING, "Unable to allocate socket: %s\n", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
flags = fcntl(udptl->fd, F_GETFL);
|
||||
fcntl(udptl->fd, F_SETFL, flags | O_NONBLOCK);
|
||||
ast_fd_set_flags(udptl->fd, O_NONBLOCK);
|
||||
|
||||
#ifdef SO_NO_CHECK
|
||||
if (cfg->general->nochecksums)
|
||||
|
Reference in New Issue
Block a user