]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
exit thread if too many errors occur to prevent endless loop
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 9 Nov 2009 18:31:48 +0000 (18:31 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 9 Nov 2009 18:31:48 +0000 (18:31 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@850 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c

index e45d3413dbbb41edab3c97b8f10b468d580463ed..3978c94106b8751e8eed858e3550a5d86334b33f 100644 (file)
@@ -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: