Ignore:
Timestamp:
Feb 13, 2008 4:59:29 PM (16 years ago)
Author:
bennylp
Message:

Ticket #460: Concurrency problem when destroying stream (thanks Michael Broughton)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c

    r1763 r1790  
    320320        goto on_error; 
    321321     
     322    /* Disallow concurrency so that detach() and destroy() are 
     323     * synchronized with the callback. 
     324     */ 
     325    status = pj_ioqueue_set_concurrency(tp->rtp_key, PJ_FALSE); 
     326    if (status != PJ_SUCCESS) 
     327        goto on_error; 
     328 
    322329    pj_ioqueue_op_key_init(&tp->rtp_read_op, sizeof(tp->rtp_read_op)); 
    323330    for (i=0; i<PJ_ARRAY_SIZE(tp->rtp_pending_write); ++i) 
     
    344351        goto on_error; 
    345352 
     353    status = pj_ioqueue_set_concurrency(tp->rtcp_key, PJ_FALSE); 
     354    if (status != PJ_SUCCESS) 
     355        goto on_error; 
     356 
    346357    pj_ioqueue_op_key_init(&tp->rtcp_read_op, sizeof(tp->rtcp_read_op)); 
    347358    pj_ioqueue_op_key_init(&tp->rtcp_write_op, sizeof(tp->rtcp_write_op)); 
     
    384395 
    385396    if (udp->rtp_key) { 
     397        /* This will block the execution if callback is still 
     398         * being called. 
     399         */ 
    386400        pj_ioqueue_unregister(udp->rtp_key); 
    387401        udp->rtp_key = NULL; 
     
    646660 
    647661    if (udp->attached) { 
     662        /* Lock the ioqueue keys to make sure that callbacks are 
     663         * not executed. See ticket #460 for details. 
     664         */ 
     665        pj_ioqueue_lock_key(udp->rtp_key); 
     666        pj_ioqueue_lock_key(udp->rtcp_key); 
     667 
    648668        /* User data is unreferenced on Release build */ 
    649669        PJ_UNUSED_ARG(user_data); 
     
    659679        udp->rtcp_cb = NULL; 
    660680        udp->user_data = NULL; 
     681 
     682        /* Unlock keys */ 
     683        pj_ioqueue_unlock_key(udp->rtcp_key); 
     684        pj_ioqueue_unlock_key(udp->rtp_key); 
    661685    } 
    662686} 
Note: See TracChangeset for help on using the changeset viewer.