Changeset 252 for pjproject


Ignore:
Timestamp:
Mar 1, 2006 7:28:08 PM (19 years ago)
Author:
bennylp
Message:

Fixed bug where rdata is not reset properly causing memory to grow indefinitely

Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_transport.h

    r145 r252  
    164164        /** The transport object which received this packet. */ 
    165165        pjsip_transport         *transport; 
     166 
     167        /** Other transport specific data to be attached to this buffer. */ 
     168        void                    *tp_data; 
    166169 
    167170        /** Ioqueue key. */ 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c

    r184 r252  
    4242 
    4343/* 
     44 * Initialize transport's receive buffer from the specified pool. 
     45 */ 
     46static void init_rdata(struct udp_transport *tp, unsigned rdata_index, 
     47                       pj_pool_t *pool, pjsip_rx_data **p_rdata) 
     48{ 
     49    pjsip_rx_data *rdata; 
     50 
     51    /* Reset pool. */ 
     52    pj_pool_reset(pool); 
     53 
     54    rdata = pj_pool_zalloc(pool, sizeof(pjsip_rx_data)); 
     55 
     56    /* Init tp_info part. */ 
     57    rdata->tp_info.pool = pool; 
     58    rdata->tp_info.transport = &tp->base; 
     59    rdata->tp_info.tp_data = (void*) rdata_index; 
     60    rdata->tp_info.op_key.rdata = rdata; 
     61    pj_ioqueue_op_key_init(&rdata->tp_info.op_key.op_key,  
     62                           sizeof(pj_ioqueue_op_key_t)); 
     63 
     64    tp->rdata[rdata_index] = rdata; 
     65 
     66    if (p_rdata) 
     67        *p_rdata = rdata; 
     68} 
     69 
     70 
     71/* 
    4472 * udp_on_read_complete() 
    4573 * 
     
    116144            flags = 0; 
    117145        } 
     146 
     147        /* Reset pool. */ 
     148        pj_pool_reset(rdata->tp_info.pool); 
     149        init_rdata((struct udp_transport*)rdata->tp_info.transport, 
     150                   (unsigned)rdata->tp_info.tp_data, 
     151                   rdata->tp_info.pool, 
     152                   &rdata); 
    118153 
    119154        /* Read next packet. */ 
     
    413448        } 
    414449 
    415         tp->rdata[i] = pj_pool_zalloc(rdata_pool, sizeof(pjsip_rx_data)); 
    416  
    417         /* Init tp_info part. */ 
    418         tp->rdata[i]->tp_info.pool = rdata_pool; 
    419         tp->rdata[i]->tp_info.transport = &tp->base; 
    420         tp->rdata[i]->tp_info.op_key.rdata = tp->rdata[i]; 
    421         pj_ioqueue_op_key_init(&tp->rdata[i]->tp_info.op_key.op_key,  
    422                                sizeof(pj_ioqueue_op_key_t)); 
    423  
     450        init_rdata(tp, i, rdata_pool, NULL); 
    424451        tp->rdata_cnt++; 
    425452    } 
Note: See TracChangeset for help on using the changeset viewer.