]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Fix for segfault on zap_queue wrap-around
authorDavid Yat Sin <dyatsin@sangoma.com>
Fri, 18 Dec 2009 20:53:17 +0000 (20:53 +0000)
committerDavid Yat Sin <dyatsin@sangoma.com>
Fri, 18 Dec 2009 20:53:17 +0000 (20:53 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@942 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/freetdm/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c
libs/freetdm/src/ozmod/ozmod_sangoma_boost/sangoma_boost_client.c
libs/freetdm/src/ozmod/ozmod_sangoma_boost/sigboost.h
libs/freetdm/src/zap_queue.c

index 66cc64009a7ec05dd36618c76dac613236737b85..5412738bb80c06801d302220fe988fcbfe8e8e0b 100644 (file)
@@ -33,7 +33,7 @@
  * Contributors: 
  *
  * Moises Silva <moy@sangoma.com>
- * David Yatzin <davidy@sangoma.com>
+ * David Yat Sin <dyatsin@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 */
                        
                        sangomabc_exec_command(mcon,
-                                               zchan->physical_span_id-1,
-                                               zchan->physical_chan_id-1,
+                                               BOOST_SPAN(zchan),
+                                               BOOST_CHAN(zchan),
                                                0,
                                                SIGBOOST_EVENT_CALL_STOPPED_ACK,
                                                0);
@@ -1036,8 +1036,8 @@ static __inline__ void state_advance(zap_channel_t *zchan)
                                zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_MSG);
 
                                sangomabc_exec_command(mcon,
-                                                          zchan->physical_span_id-1,
-                                                          zchan->physical_chan_id-1,
+                                                          BOOST_SPAN(zchan),
+                                                          BOOST_CHAN(zchan),
                                                           0,
                                                           SIGBOOST_EVENT_CALL_STOPPED_ACK,
                                                           0);
@@ -1058,8 +1058,8 @@ static __inline__ void state_advance(zap_channel_t *zchan)
                                if (!zap_test_sflag(zchan, SFLAG_SENT_ACK)) {
                                        zap_set_sflag(zchan, SFLAG_SENT_ACK);
                                                sangomabc_exec_command(mcon,
-                                                                                       zchan->physical_span_id-1,
-                                                                                       zchan->physical_chan_id-1,
+                                                                                       BOOST_SPAN(zchan),
+                                                                                       BOOST_CHAN(zchan),
                                                                                        0,
                                                                                        SIGBOOST_EVENT_CALL_START_ACK,
                                                                                        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);
                return ZAP_FAIL;
        }
-
        /* duplicate the event and enqueue it */
        element = zap_calloc(1, sizeof(*element));
        if (!element) {
index 1ba67c9834a4a256e10e23c62e82da23fe6ddf16..0af4664ee7569bde4a9bd43159688db560098679 100644 (file)
@@ -76,12 +76,13 @@ static void sangomabc_print_event_call(sangomabc_connection_t *mcon, sangomabc_e
        if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
                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",
-                   dir ? "TX":"RX", 
+       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",
+                       priority ? "P":"N",
                        sangomabc_event_id_name(event->event_id),
                        event->event_id,
-                       event->span+1,
-                       event->chan+1,
+                       event->span,
+                       event->chan,
                        event->call_setup_id,
                        event->fseqno,
                        strlen(event->calling_name)?event->calling_name:"N/A",
@@ -94,9 +95,9 @@ static void sangomabc_print_event_short(sangomabc_connection_t *mcon, sangomabc_
 {
        if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
                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", 
-                          priority ? "P":"N",  
+                          priority ? "P":"N",
                            sangomabc_event_id_name(event->event_id), 
                            event->event_id, 
                            event->span, 
@@ -322,8 +323,7 @@ sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int
                msg_ok=0;
        }
 
-       if (msg_ok){
-
+       if (msg_ok) {
                if (sangomabc_test_flag(mcon, MSU_FLAG_DOWN)) {
                        if (mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART && 
                                mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK && 
@@ -333,7 +333,7 @@ sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int
                                return NULL;
                        }
                }
-
+               
                if  (boost_full_event(mcon->event.event_id)) {
                        sangomabc_print_event_call(mcon, &mcon->event, 0, 0, file, func, line);
                } else {
index 47849c2c723292236c27ecae294492a62cc07714..9e97e9014d977decd189ba2ee1239ba85f8ea9bd 100644 (file)
@@ -147,7 +147,7 @@ static __inline__ int boost_full_event(int event_id)
         switch (event_id) {
         case SIGBOOST_EVENT_CALL_START:
         case SIGBOOST_EVENT_DIGIT_IN:
-               case SIGBOOST_EVENT_CALL_PROGRESS:
+       case SIGBOOST_EVENT_CALL_PROGRESS:
                 return 1;
         default:
                        break;
index 969e1707834ab6f1bd25f9b1e0c2b68a507b7747..a714af340c872dc5a01d8b41672839e349188880 100644 (file)
@@ -163,7 +163,7 @@ static void *zap_std_queue_dequeue(zap_queue_t *queue)
        obj = queue->elements[queue->rindex];
        queue->elements[queue->rindex++] = NULL;
        queue->size--;
-       if (queue->rindex == queue->size) {
+       if (queue->rindex == queue->capacity) {
                queue->rindex = 0;
        }