From c1323ecf10d932b99025ec6bde7c7ac85bcb1fba Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 9 Nov 2009 18:31:48 +0000 Subject: [PATCH] exit thread if too many errors occur to prevent endless loop git-svn-id: http://svn.openzap.org/svn/openzap/trunk@850 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/src/ozmod/ozmod_analog/ozmod_analog.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/freetdm/src/ozmod/ozmod_analog/ozmod_analog.c b/libs/freetdm/src/ozmod/ozmod_analog/ozmod_analog.c index e45d3413db..3978c94106 100644 --- a/libs/freetdm/src/ozmod/ozmod_analog/ozmod_analog.c +++ b/libs/freetdm/src/ozmod/ozmod_analog/ozmod_analog.c @@ -922,14 +922,17 @@ static void *zap_analog_run(zap_thread_t *me, void *obj) { zap_span_t *span = (zap_span_t *) obj; zap_analog_data_t *analog_data = span->signal_data; - + int errs = 0; + zap_log(ZAP_LOG_DEBUG, "ANALOG thread starting.\n"); while(zap_running() && zap_test_flag(analog_data, ZAP_ANALOG_RUNNING)) { int waitms = 1000; zap_status_t status; - status = zap_span_poll_event(span, waitms); + if ((status = zap_span_poll_event(span, waitms)) != ZAP_FAIL) { + errs = 0; + } switch(status) { case ZAP_SUCCESS: @@ -948,6 +951,10 @@ static void *zap_analog_run(zap_thread_t *me, void *obj) case ZAP_FAIL: { zap_log(ZAP_LOG_ERROR, "Failure Polling event! [%s]\n", span->last_error); + if (++errs > 300) { + zap_log(ZAP_LOG_CRIT, "Too Many Errors!\n"); + goto end; + } } break; default: