Index: res/res_agi.c =================================================================== --- res/res_agi.c (revision 76711) +++ res/res_agi.c (working copy) @@ -115,7 +115,7 @@ AGI_RESULT_HANGUP }; -static void agi_debug_cli(int fd, char *fmt, ...) +static int agi_debug_cli(int fd, char *fmt, ...) { char *stuff; int res = 0; @@ -129,9 +129,11 @@ } else { if (agidebug) ast_verbose("AGI Tx >> %s", stuff); /* \n provided by caller */ - ast_carefulwrite(fd, stuff, strlen(stuff), 100); + res = ast_carefulwrite(fd, stuff, strlen(stuff), 100); free(stuff); } + + return res; } /* launch_netscript: The fastagi handler. @@ -210,8 +212,9 @@ 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) { + + res = fdprintf(s, "agi_network: yes\n"); + if (res < 0) { if (errno != EINTR) { ast_log(LOG_WARNING, "Connect to '%s' failed: %s\n", agiurl, strerror(errno)); close(s);