fix hunting of zchan on incoming calls and event reading bug

git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@904 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Moises Silva 2009-11-25 20:18:29 +00:00
parent bd00467c76
commit bea687fb76
2 changed files with 17 additions and 12 deletions

View File

@ -191,10 +191,18 @@ static zap_channel_t *find_zchan(zap_span_t *span, sangomabc_short_event_t *even
{
int i;
zap_channel_t *zchan = NULL;
zap_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
int targetspan = event->span+1;
int targetchan = event->chan+1;
if (sangoma_boost_data->sigmod) {
/* span is not strictly needed here since we're supposed to get only events for our span */
targetspan = event->span;
targetchan = event->chan;
}
zap_mutex_lock(signal_mutex);
for(i = 1; i <= span->chan_count; i++) {
if (span->channels[i]->physical_span_id == event->span+1 && span->channels[i]->physical_chan_id == event->chan+1) {
if (span->channels[i]->physical_span_id == targetspan && span->channels[i]->physical_chan_id == targetchan) {
zchan = span->channels[i];
if (force || (zchan->state == ZAP_CHANNEL_STATE_DOWN && !zap_test_flag(zchan, ZAP_CHANNEL_INUSE))) {
break;
@ -1549,7 +1557,7 @@ static BOOST_WRITE_MSG_FUNCTION(zap_boost_write_msg)
if (!element) {
return ZAP_FAIL;
}
memcpy(&element->boostmsg, msg, msglen);
memcpy(element->boostmsg, msg, msglen);
element->size = msglen;
sangoma_boost_data = span->signal_data;

View File

@ -277,9 +277,11 @@ sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int
if (mcon->sigmod) {
e = zap_queue_dequeue(mcon->boost_queue);
bytes = e->size;
memcpy(&mcon->event, e->boostmsg, bytes);
zap_safe_free(e);
if (e) {
bytes = e->size;
memcpy(&mcon->event, e->boostmsg, bytes);
zap_safe_free(e);
}
} else {
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT,
(struct sockaddr *) &mcon->local_addr, &fromlen);
@ -364,15 +366,10 @@ sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, in
{
unsigned int fromlen = sizeof(struct sockaddr_in);
int bytes = 0;
sangomabc_queue_element_t *e = NULL;
if (mcon->sigmod) {
e = zap_queue_dequeue(mcon->boost_queue);
if (e) {
bytes = e->size;
memcpy(&mcon->event, e->boostmsg, bytes);
zap_safe_free(e);
}
/* priority stuff is handled just the same when there is a sigmod */
return sangomabc_connection_read(mcon, iteration);
} else {
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT, (struct sockaddr *) &mcon->local_addr, &fromlen);
}