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:
@@ -650,7 +650,7 @@ static struct cops_gate *cops_gate_cmd(int cmd, struct cops_cmts *cmts,
|
||||
|
||||
static int cops_connect(char *host, char *port)
|
||||
{
|
||||
int s, sfd = -1, flags;
|
||||
int s, sfd = -1;
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *rp;
|
||||
struct addrinfo *result;
|
||||
@@ -676,8 +676,7 @@ static int cops_connect(char *host, char *port)
|
||||
if (sfd == -1) {
|
||||
ast_log(LOG_WARNING, "Failed socket\n");
|
||||
}
|
||||
flags = fcntl(sfd, F_GETFL);
|
||||
fcntl(sfd, F_SETFL, flags | O_NONBLOCK);
|
||||
ast_fd_set_flags(sfd, O_NONBLOCK);
|
||||
#ifdef HAVE_SO_NOSIGPIPE
|
||||
setsockopt(sfd, SOL_SOCKET, SO_NOSIGPIPE, &trueval, sizeof(trueval));
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user