diff --git a/res/res_agi.c b/res/res_agi.c index b1f4736..9cf12dd 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -1581,9 +1581,10 @@ static enum agi_result launch_ha_netscript(char *agiurl, char *argv[], int *fds) } if (srv_ret < 0) { ast_log(LOG_WARNING, "SRV lookup failed for %s\n", agiurl); - } else { - ast_srv_cleanup(&context); - } + } else if (srv_ret == 0) { + // Broke out of the loop after launching netscript. + ast_srv_cleanup(&context); + } return result; }