aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/asterisk/agi.h2
-rw-r--r--res/res_agi.c10
2 files changed, 7 insertions, 5 deletions
diff --git a/include/asterisk/agi.h b/include/asterisk/agi.h
index 584ddfe03..4be6565dc 100644
--- a/include/asterisk/agi.h
+++ b/include/asterisk/agi.h
@@ -51,7 +51,7 @@ typedef struct agi_command {
AST_LIST_ENTRY(agi_command) list;
} agi_command;
-void ast_agi_fdprintf(int fd, char *fmt, ...);
+int ast_agi_fdprintf(int fd, char *fmt, ...);
int ast_agi_register(struct ast_module *mod, agi_command *cmd);
int ast_agi_unregister(struct ast_module *mod, agi_command *cmd);
void ast_agi_register_multiple(struct ast_module *mod, agi_command *cmd, int len);
diff --git a/res/res_agi.c b/res/res_agi.c
index 003cefac5..023d8d131 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -115,7 +115,7 @@ enum agi_result {
static agi_command *find_command(char *cmds[], int exact);
-void ast_agi_fdprintf(int fd, char *fmt, ...)
+int ast_agi_fdprintf(int fd, char *fmt, ...)
{
char *stuff;
int res = 0;
@@ -127,13 +127,15 @@ void ast_agi_fdprintf(int fd, char *fmt, ...)
if (res == -1) {
ast_log(LOG_ERROR, "Out of memory\n");
- return;
+ return -1;
}
if (agidebug)
ast_verbose("AGI Tx >> %s", stuff);
ast_carefulwrite(fd, stuff, strlen(stuff), 100);
ast_free(stuff);
+
+ return res;
}
/* launch_netscript: The fastagi handler.
@@ -205,8 +207,8 @@ static enum agi_result launch_netscript(char *agiurl, char *argv[], int *fds, in
return AGI_RESULT_FAILURE;
}
}
- /* XXX in theory should check for partial writes... */
- while (write(s, "agi_network: yes\n", strlen("agi_network: yes\n")) < 0) {
+
+ if (ast_agi_fdprintf(s, "agi_network: yes\n") < 0) {
if (errno != EINTR) {
ast_log(LOG_WARNING, "Connect to '%s' failed: %s\n", agiurl, strerror(errno));
close(s);