summaryrefslogtreecommitdiff
path: root/res/res_agi.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_agi.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_agi.c')
-rw-r--r--res/res_agi.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index 13af48f49..85914c018 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -2046,7 +2046,7 @@ static int handle_connection(const char *agiurl, const struct ast_sockaddr addr,
FastAGI defaults to port 4573 */
static enum agi_result launch_netscript(char *agiurl, char *argv[], int *fds)
{
- int s = 0, flags;
+ int s = 0;
char *host, *script;
int num_addrs = 0, i = 0;
struct ast_sockaddr *addrs;
@@ -2076,14 +2076,7 @@ static enum agi_result launch_netscript(char *agiurl, char *argv[], int *fds)
continue;
}
- if ((flags = fcntl(s, F_GETFL)) < 0) {
- ast_log(LOG_WARNING, "fcntl(F_GETFL) failed: %s\n", strerror(errno));
- close(s);
- continue;
- }
-
- if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0) {
- ast_log(LOG_WARNING, "fnctl(F_SETFL) failed: %s\n", strerror(errno));
+ if (ast_fd_set_flags(s, O_NONBLOCK)) {
close(s);
continue;
}
@@ -2249,9 +2242,8 @@ static enum agi_result launch_script(struct ast_channel *chan, char *script, int
close(toast[1]);
return AGI_RESULT_FAILURE;
}
- res = fcntl(audio[1], F_GETFL);
- if (res > -1)
- res = fcntl(audio[1], F_SETFL, res | O_NONBLOCK);
+
+ res = ast_fd_set_flags(audio[1], O_NONBLOCK);
if (res < 0) {
ast_log(LOG_WARNING, "unable to set audio pipe parameters: %s\n", strerror(errno));
close(fromast[0]);