mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +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:
@@ -3048,8 +3048,7 @@ static int create_new_socket(const char *type, int af)
|
||||
}
|
||||
ast_log(LOG_WARNING, "Unable to allocate %s socket: %s\n", type, strerror(errno));
|
||||
} else {
|
||||
long flags = fcntl(sock, F_GETFL);
|
||||
fcntl(sock, F_SETFL, flags | O_NONBLOCK);
|
||||
ast_fd_set_flags(sock, O_NONBLOCK);
|
||||
#ifdef SO_NO_CHECK
|
||||
if (nochecksums) {
|
||||
setsockopt(sock, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums));
|
||||
|
Reference in New Issue
Block a user