Fix for segfault on zap_queue wrap-around

git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@942 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
David Yat Sin 2009-12-18 20:53:17 +00:00
parent 6f1cafa983
commit b433175950
4 changed files with 18 additions and 19 deletions

View File

@ -33,7 +33,7 @@
* Contributors: * Contributors:
* *
* Moises Silva <moy@sangoma.com> * Moises Silva <moy@sangoma.com>
* David Yatzin <davidy@sangoma.com> * David Yat Sin <dyatsin@sangoma.com>
* Nenad Corbic <ncorbic@sangoma.com> * Nenad Corbic <ncorbic@sangoma.com>
* *
*/ */
@ -711,8 +711,8 @@ static void handle_call_stop(zap_span_t *span, sangomabc_connection_t *mcon, san
* itself through local initiated hangup */ * itself through local initiated hangup */
sangomabc_exec_command(mcon, sangomabc_exec_command(mcon,
zchan->physical_span_id-1, BOOST_SPAN(zchan),
zchan->physical_chan_id-1, BOOST_CHAN(zchan),
0, 0,
SIGBOOST_EVENT_CALL_STOPPED_ACK, SIGBOOST_EVENT_CALL_STOPPED_ACK,
0); 0);
@ -1036,8 +1036,8 @@ static __inline__ void state_advance(zap_channel_t *zchan)
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_MSG); zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_MSG);
sangomabc_exec_command(mcon, sangomabc_exec_command(mcon,
zchan->physical_span_id-1, BOOST_SPAN(zchan),
zchan->physical_chan_id-1, BOOST_CHAN(zchan),
0, 0,
SIGBOOST_EVENT_CALL_STOPPED_ACK, SIGBOOST_EVENT_CALL_STOPPED_ACK,
0); 0);
@ -1058,8 +1058,8 @@ static __inline__ void state_advance(zap_channel_t *zchan)
if (!zap_test_sflag(zchan, SFLAG_SENT_ACK)) { if (!zap_test_sflag(zchan, SFLAG_SENT_ACK)) {
zap_set_sflag(zchan, SFLAG_SENT_ACK); zap_set_sflag(zchan, SFLAG_SENT_ACK);
sangomabc_exec_command(mcon, sangomabc_exec_command(mcon,
zchan->physical_span_id-1, BOOST_SPAN(zchan),
zchan->physical_chan_id-1, BOOST_CHAN(zchan),
0, 0,
SIGBOOST_EVENT_CALL_START_ACK, SIGBOOST_EVENT_CALL_START_ACK,
0); 0);
@ -1716,7 +1716,6 @@ static BOOST_WRITE_MSG_FUNCTION(zap_boost_write_msg)
zap_log(ZAP_LOG_ERROR, "Unexpected boost message %d\n", shortmsg->event_id); zap_log(ZAP_LOG_ERROR, "Unexpected boost message %d\n", shortmsg->event_id);
return ZAP_FAIL; return ZAP_FAIL;
} }
/* duplicate the event and enqueue it */ /* duplicate the event and enqueue it */
element = zap_calloc(1, sizeof(*element)); element = zap_calloc(1, sizeof(*element));
if (!element) { if (!element) {

View File

@ -76,12 +76,13 @@ static void sangomabc_print_event_call(sangomabc_connection_t *mcon, sangomabc_e
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT) if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
return; return;
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "%s EVENT: %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s] Rdnis=[%s]\n", zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "%s EVENT (%s): %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s] Rdnis=[%s]\n",
dir ? "TX":"RX", dir ? "TX":"RX",
priority ? "P":"N",
sangomabc_event_id_name(event->event_id), sangomabc_event_id_name(event->event_id),
event->event_id, event->event_id,
event->span+1, event->span,
event->chan+1, event->chan,
event->call_setup_id, event->call_setup_id,
event->fseqno, event->fseqno,
strlen(event->calling_name)?event->calling_name:"N/A", strlen(event->calling_name)?event->calling_name:"N/A",
@ -94,7 +95,7 @@ static void sangomabc_print_event_short(sangomabc_connection_t *mcon, sangomabc_
{ {
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT) if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
return; return;
zap_log(file, func, line, ZAP_LOG_LEVEL_DEBUG, "%s EVENT (%s): %s:(%X) [s%dc%d] Rc=%i CSid=%i Seq=%i \n", zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "%s EVENT (%s): %s:(%X) [s%dc%d] Rc=%i CSid=%i Seq=%i \n",
dir ? "TX":"RX", dir ? "TX":"RX",
priority ? "P":"N", priority ? "P":"N",
sangomabc_event_id_name(event->event_id), sangomabc_event_id_name(event->event_id),
@ -323,7 +324,6 @@ sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int
} }
if (msg_ok) { if (msg_ok) {
if (sangomabc_test_flag(mcon, MSU_FLAG_DOWN)) { if (sangomabc_test_flag(mcon, MSU_FLAG_DOWN)) {
if (mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART && if (mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK && mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&

View File

@ -163,7 +163,7 @@ static void *zap_std_queue_dequeue(zap_queue_t *queue)
obj = queue->elements[queue->rindex]; obj = queue->elements[queue->rindex];
queue->elements[queue->rindex++] = NULL; queue->elements[queue->rindex++] = NULL;
queue->size--; queue->size--;
if (queue->rindex == queue->size) { if (queue->rindex == queue->capacity) {
queue->rindex = 0; queue->rindex = 0;
} }