diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 2c80242b84..43c6e05d2f 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -915,7 +915,10 @@ static int __schedule_action(void (*func)(void *data), void *data, const char *f static void __send_ping(void *data) { int callno = (long)data; - send_command_locked(callno, AST_FRAME_IAX, IAX_COMMAND_PING, 0, NULL, 0, -1); + ast_mutex_lock(&iaxsl[callno]); + if (iaxs[callno]) + send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_PING, 0, NULL, 0, -1); + ast_mutex_unlock(&iaxsl[callno]); } static int send_ping(void *data) @@ -948,7 +951,10 @@ static void __send_lagrq(void *data) { int callno = (long)data; /* Ping only if it's real not if it's bridged */ - send_command_locked(callno, AST_FRAME_IAX, IAX_COMMAND_LAGRQ, 0, NULL, 0, -1); + ast_mutex_lock(&iaxsl[callno]); + if (iaxs[callno]) + send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_LAGRQ, 0, NULL, 0, -1); + ast_mutex_unlock(&iaxsl[callno]); } static int send_lagrq(void *data)