freetdm: only handle zt events when FTDM_CHANNEL_EVENT is set

This commit is contained in:
Moises Silva 2011-01-06 14:54:19 -05:00
parent 81f01f0ee7
commit 3018400461

View File

@ -1131,26 +1131,26 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
ftdm_channel_t *fchan = span->channels[i]; ftdm_channel_t *fchan = span->channels[i];
if (ftdm_test_flag(fchan, FTDM_CHANNEL_EVENT)) { if (ftdm_test_flag(fchan, FTDM_CHANNEL_EVENT)) {
ftdm_clear_flag(fchan, FTDM_CHANNEL_EVENT); ftdm_clear_flag(fchan, FTDM_CHANNEL_EVENT);
} if (ioctl(fchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) {
if (ioctl(fchan->sockfd, codes.GETEVENT, &zt_event_id) == -1) { snprintf(span->last_error, sizeof(span->last_error), "%s", strerror(errno));
snprintf(span->last_error, sizeof(span->last_error), "%s", strerror(errno)); return FTDM_FAIL;
return FTDM_FAIL; }
}
ftdm_channel_lock(fchan); ftdm_channel_lock(fchan);
if ((zt_channel_process_event(fchan, &event_id, zt_event_id)) != FTDM_SUCCESS) { if ((zt_channel_process_event(fchan, &event_id, zt_event_id)) != FTDM_SUCCESS) {
ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Failed to process event from channel\n"); ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Failed to process event from channel\n");
ftdm_channel_unlock(fchan);
return FTDM_FAIL;
}
ftdm_channel_unlock(fchan); ftdm_channel_unlock(fchan);
return FTDM_FAIL;
}
ftdm_channel_unlock(fchan);
fchan->last_event_time = 0; fchan->last_event_time = 0;
span->event_header.e_type = FTDM_EVENT_OOB; span->event_header.e_type = FTDM_EVENT_OOB;
span->event_header.enum_id = event_id; span->event_header.enum_id = event_id;
span->event_header.channel = fchan; span->event_header.channel = fchan;
*event = &span->event_header; *event = &span->event_header;
return FTDM_SUCCESS; return FTDM_SUCCESS;
}
} }
return FTDM_FAIL; return FTDM_FAIL;