Skip to content

Commit d73f575

Browse files
author
skladis
committed
fix lock of speech_channel_destroy due to infinite loop on apr_thread_cond_timedwait()
1 parent f16eacb commit d73f575

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

app-unimrcp/speech_channel.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,18 +355,15 @@ int speech_channel_destroy(speech_channel_t *schannel)
355355

356356
/* Destroy the channel and session if not already done. */
357357
if (schannel->state != SPEECH_CHANNEL_CLOSED) {
358-
int warned = 0;
359-
360358
if ((schannel->unimrcp_session != NULL) && (schannel->unimrcp_channel != NULL)) {
361359
if (!mrcp_application_session_terminate(schannel->unimrcp_session))
362360
ast_log(LOG_WARNING, "(%s) Unable to terminate application session\n", schannel->name);
363361
}
364362

365363
ast_log(LOG_DEBUG, "(%s) Waiting for MRCP session to terminate\n", schannel->name);
366-
while (schannel->state != SPEECH_CHANNEL_CLOSED) {
364+
if (schannel->state != SPEECH_CHANNEL_CLOSED) {
367365
if (schannel->cond != NULL) {
368-
if ((apr_thread_cond_timedwait(schannel->cond, schannel->mutex, globals.speech_channel_timeout) == APR_TIMEUP) && (!warned)) {
369-
warned = 1;
366+
if (apr_thread_cond_timedwait(schannel->cond, schannel->mutex, globals.speech_channel_timeout) == APR_TIMEUP) {
370367
ast_log(LOG_WARNING, "(%s) MRCP session has not terminated after %" APR_TIME_T_FMT " ms\n", schannel->name, apr_time_as_msec(globals.speech_channel_timeout));
371368
}
372369
}

0 commit comments

Comments
 (0)