Changeset 110


Ignore:
Timestamp:
Jan 7, 2006 11:01:13 PM (18 years ago)
Author:
bennylp
Message:

Added prev_state in tsx_state event

Location:
pjproject/trunk/pjsip/src/pjsip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_transaction.c

    r109 r110  
    893893                           void *event_src ) 
    894894{ 
     895    pjsip_tsx_state_e prev_state = tsx->state; 
     896 
    895897    PJ_LOG(5, (tsx->obj_name, "State changed from %s to %s, event=%s", 
    896898               state_str[tsx->state], state_str[state],  
     
    910912    if (tsx->tsx_user && tsx->tsx_user->on_tsx_state) { 
    911913        pjsip_event e; 
    912         PJSIP_EVENT_INIT_TSX_STATE(e, tsx, event_src_type, event_src); 
     914        PJSIP_EVENT_INIT_TSX_STATE(e, tsx, event_src_type, event_src, 
     915                                   prev_state); 
    913916        (*tsx->tsx_user->on_tsx_state)(tsx, &e); 
    914917    } 
     
    21072110        pjsip_endpt_schedule_timer( tsx->endpt, &tsx->timeout_timer, &timeout); 
    21082111 
    2109         /* Inform TU. */ 
     2112        /* Inform TU.  
     2113         * blp: You might be tempted to move this notification before 
     2114         *      sending ACK, but I think you shouldn't. Better set-up 
     2115         *      everything before calling tsx_user's callback to avoid 
     2116         *      mess up. 
     2117         */ 
    21102118        tsx_set_state( tsx, PJSIP_TSX_STATE_COMPLETED,  
    21112119                       PJSIP_EVENT_RX_MSG, event->body.rx_msg.rdata ); 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_loop.c

    r109 r110  
    254254{ 
    255255    struct loop_transport *loop = arg; 
     256    struct recv_list r; 
     257    struct send_list s; 
     258 
     259    pj_list_init(&r); 
     260    pj_list_init(&s); 
    256261 
    257262    while (!loop->thread_quit_flag) { 
     
    263268        pj_lock_acquire(loop->base.lock); 
    264269 
    265         /* Process pending send notification. */ 
     270        /* Move expired send notification to local list. */ 
    266271        while (!pj_list_empty(&loop->send_list)) { 
    267272            struct send_list *node = loop->send_list.next; 
     
    270275            if (PJ_TIME_VAL_GTE(node->sent_time, now)) 
    271276                break; 
     277 
     278            /* Delete this from the list. */ 
     279            pj_list_erase(node); 
     280 
     281            /* Add to local list. */ 
     282            pj_list_push_back(&s, node); 
     283        } 
     284 
     285        /* Move expired "incoming" packet to local list. */ 
     286        while (!pj_list_empty(&loop->recv_list)) { 
     287            struct recv_list *node = loop->recv_list.next; 
     288 
     289            /* Break when next node time is greater than now. */ 
     290            if (PJ_TIME_VAL_GTE(node->rdata.pkt_info.timestamp, now)) 
     291                break; 
     292 
     293            /* Delete this from the list. */ 
     294            pj_list_erase(node); 
     295 
     296            /* Add to local list. */ 
     297            pj_list_push_back(&r, node); 
     298 
     299        } 
     300 
     301        pj_lock_release(loop->base.lock); 
     302 
     303        /* Process send notification and incoming packet notification 
     304         * without holding down the loop's mutex. 
     305         */ 
     306        while (!pj_list_empty(&s)) { 
     307            struct send_list *node = s.next; 
     308 
     309            pj_list_erase(node); 
    272310 
    273311            /* Notify callback. */ 
     
    276314            } 
    277315 
    278             /* Delete this from the list. */ 
    279             pj_list_erase(node); 
    280  
    281316            /* Decrement tdata reference counter. */ 
    282317            pjsip_tx_data_dec_ref(node->tdata); 
    283318        } 
    284319 
    285         /* Process "incoming" packets. */ 
    286         while (!pj_list_empty(&loop->recv_list)) { 
    287             struct recv_list *node = loop->recv_list.next; 
     320        /* Process "incoming" packet. */ 
     321        while (!pj_list_empty(&r)) { 
     322            struct recv_list *node = r.next; 
    288323            pj_ssize_t size_eaten; 
    289324 
    290             /* Break when next node time is greater than now. */ 
    291             if (PJ_TIME_VAL_GTE(node->rdata.pkt_info.timestamp, now)) 
    292                 break; 
     325            pj_list_erase(node); 
    293326 
    294327            /* Notify transport manager about the "incoming packet" */ 
     
    298331            /* Must "eat" all the packets. */ 
    299332            pj_assert(size_eaten == node->rdata.pkt_info.len); 
    300  
    301             /* Delete this from the list. */ 
    302             pj_list_erase(node); 
    303333 
    304334            /* Done. */ 
     
    306336                                     node->rdata.tp_info.pool); 
    307337        } 
    308  
    309         pj_lock_release(loop->base.lock); 
    310338    } 
    311339 
Note: See TracChangeset for help on using the changeset viewer.