summaryrefslogtreecommitdiff
path: root/res/res_pktccops.c
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-12-07 10:52:39 -0500
committerSean Bright <sean.bright@gmail.com>2017-12-08 13:28:04 -0600
commit2ffe52a116ad05d060cbedda93c48cf5a4415ca3 (patch)
tree9f8d99288f532ad213b8681e7616c26e8535df24 /res/res_pktccops.c
parentb0b28446c1e5f76c54b823bc3f4e2a5423c9c79b (diff)
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
Diffstat (limited to 'res/res_pktccops.c')
-rw-r--r--res/res_pktccops.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/res/res_pktccops.c b/res/res_pktccops.c
index e8d266cda..156c49dc7 100644
--- a/res/res_pktccops.c
+++ b/res/res_pktccops.c
@@ -648,7 +648,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;
@@ -674,8 +674,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