Changeset 1790


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

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

Location:
pjproject/trunk
Files:
4 edited

Legend:

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

    r1780 r1790  
    14001400 
    14011401 
     1402    /* Detach from transport  
     1403     * MUST NOT hold stream mutex while detaching from transport, as 
     1404     * it may cause deadlock. See ticket #460 for the details. 
     1405     */ 
     1406    if (stream->transport) { 
     1407        pjmedia_transport_detach(stream->transport, stream); 
     1408        stream->transport = NULL; 
     1409    } 
     1410 
    14021411    /* This function may be called when stream is partly initialized. */ 
    14031412    if (stream->jb_mutex) 
    14041413        pj_mutex_lock(stream->jb_mutex); 
    14051414 
    1406  
    1407     /* Detach from transport */ 
    1408     if (stream->transport) { 
    1409         (*stream->transport->op->detach)(stream->transport, stream); 
    1410         stream->transport = NULL; 
    1411     } 
    14121415 
    14131416    /* Free codec. */ 
  • pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c

    r1763 r1790  
    699699    struct transport_ice *tp_ice = (struct transport_ice*)tp; 
    700700 
     701    /* TODO: need to solve ticket #460 here */ 
     702 
    701703    tp_ice->rtp_cb = NULL; 
    702704    tp_ice->rtcp_cb = NULL; 
  • 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} 
  • pjproject/trunk/pjnath/src/pjnath/ice_strans.c

    r1731 r1790  
    329329                                      comp->sock, comp, &ioqueue_cb,  
    330330                                      &comp->key); 
     331    if (status != PJ_SUCCESS) 
     332        goto on_error; 
     333 
     334    /* Disable concurrency */ 
     335    status = pj_ioqueue_set_concurrency(comp->key, PJ_FALSE); 
    331336    if (status != PJ_SUCCESS) 
    332337        goto on_error; 
Note: See TracChangeset for help on using the changeset viewer.