Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 131480) +++ channels/chan_iax2.c (working copy) @@ -1051,8 +1051,8 @@ /* I am the schedule, so I'm allowed to do this */ iaxs[callno]->lagid = -1; } - } else if (option_debug > 0) { - ast_log(LOG_DEBUG, "I was supposed to send a LAGRQ with callno %d, but no such call exists (and I cannot remove lagid, either).\n", callno); + } else { + ast_log(LOG_ERROR, "I was supposed to send a LAGRQ with callno %d, but no such call exists (and I cannot remove lagid, either).\n", callno); } ast_mutex_unlock(&iaxsl[callno]); @@ -1618,10 +1618,10 @@ snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port)); now = ast_tvnow(); - start = 1 + (ast_random() % (TRUNK_CALL_START - 1)); + start = 2 + (ast_random() % (TRUNK_CALL_START - 1)); for (x = start; 1; x++) { if (x == TRUNK_CALL_START) { - x = 0; + x = 1; continue; } @@ -2147,6 +2147,15 @@ return res; } +static int send_apathetic_reply(unsigned short callno, unsigned short dcallno, struct sockaddr_in *sin, int command, int ts, unsigned char seqno) +{ + struct ast_iax2_full_hdr f = { .scallno = htons(0x8000 | callno), .dcallno = htons(dcallno), + .ts = htonl(ts), .iseqno = seqno, .oseqno = seqno, .type = AST_FRAME_IAX, + .csub = compress_subclass(command) }; + + return sendto(defaultsockfd, &f, sizeof(f), 0, (struct sockaddr *)sin, sizeof(*sin)); +} + /*! * \note Since this function calls iax2_queue_hangup(), the pvt struct * for the given call number may disappear during its execution. @@ -7180,6 +7189,17 @@ } else { f.subclass = uncompress_subclass(fh->csub); } + + /* Deal with POKE/PONG without allocating a callno */ + if (f.frametype == AST_FRAME_IAX && f.subclass == IAX_COMMAND_POKE) { + /* Reply back with a PONG, but don't care about the result. */ + send_apathetic_reply(1, ntohs(fh->scallno), &sin, IAX_COMMAND_PONG, ntohs(fh->ts), fh->oseqno); + return 1; + } else if (f.frametype == AST_FRAME_IAX && f.subclass == IAX_COMMAND_ACK && dcallno == 1) { + /* Ignore */ + return 1; + } + if ((f.frametype == AST_FRAME_IAX) && ((f.subclass == IAX_COMMAND_NEW) || (f.subclass == IAX_COMMAND_REGREQ) || (f.subclass == IAX_COMMAND_POKE) || (f.subclass == IAX_COMMAND_FWDOWNL) || (f.subclass == IAX_COMMAND_REGREL))) Index: include/asterisk/sched.h =================================================================== --- include/asterisk/sched.h (revision 131479) +++ include/asterisk/sched.h (working copy) @@ -118,7 +118,8 @@ * \param id ID of the scheduled item to delete * \return Returns 0 on success, -1 on failure */ -int ast_sched_del(struct sched_context *con, int id); +int _ast_sched_del(struct sched_context *con, int id, const char *file, int line, const char *function); +#define ast_sched_del(a, b) _ast_sched_del(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! \brief Determines number of seconds until the next outstanding event to take place * Determine the number of seconds until the next outstanding event Index: main/sched.c =================================================================== --- main/sched.c (revision 131479) +++ main/sched.c (working copy) @@ -255,7 +255,7 @@ * would be two or more in the list with that * id. */ -int ast_sched_del(struct sched_context *con, int id) +int _ast_sched_del(struct sched_context *con, int id, const char *file, int line, const char *function) { struct sched *s; @@ -282,7 +282,7 @@ if (!s) { if (option_debug) ast_log(LOG_DEBUG, "Attempted to delete nonexistent schedule entry %d!\n", id); - ast_assert(s != NULL); + _ast_assert(0, "s != NULL", file, line, function); return -1; }