Changeset 8925

Show
Ignore:
Timestamp:
07/08/11 15:47:24 (2 years ago)
Author:
bligon
Message:

Corrected memory leak: when an operation completes, the PINT_manager_complete_op function removes the operation
from the io_manager's list but does not free the operation structure or remove the op-id from the registered list,
causing a memory leak. To correct, the op-id is unregistered and the op structure is freed after the
PINT_manager_complete_op() function is called.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/Orange-Branch/src/common/mgmt/pint-worker-threaded-queues.c

    r8869 r8925  
    7575            gen_cond_destroy(&w->cond); 
    7676        } 
     77        gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d:thread #%d.\n" 
     78                                      ,__func__ 
     79                                      ,(int)w->threads[i].thread_id,i); 
    7780    } 
    7881 
     
    338341    gen_mutex_unlock(&thread->mutex); 
    339342 
     343    gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread-id %d:worker location is %p: manager location is %p.\n" 
     344                                  ,__func__ 
     345                                  ,(int)thread->thread_id 
     346                                  ,worker 
     347                                  ,manager); 
     348 
    340349    gen_mutex_lock(&worker->mutex); 
    341350    op_count = worker->attr.ops_per_queue; 
     
    347356    gen_mutex_unlock(&worker->mutex); 
    348357 
     358    gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread-id %d:op-count is %d:timeout is %d.\n" 
     359                                  ,__func__ 
     360                                  ,(int)thread->thread_id 
     361                                  ,op_count 
     362                                  ,timeout); 
    349363    qentries = malloc(sizeof(PINT_queue_entry_t *) * op_count); 
    350364    if(!qentries) 
     
    357371    gen_mutex_lock(&thread->mutex); 
    358372    thread->running = 1; 
     373    gossip_debug(GOSSIP_MGMT_DEBUG,"%s: starting thread function for thread_id %d\n" 
     374                                  ,__func__ 
     375                                  ,(int)thread->thread_id); 
    359376    while(thread->running) 
    360377    { 
     
    421438            if(op_count > 0) 
    422439            { 
     440                gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d: op_count is %d.\n" 
     441                                              ,__func__ 
     442                                              ,(int)thread->thread_id,op_count); 
    423443                for(i = 0; i < op_count; ++i) 
    424444                { 
     445                    struct PINT_op_entry *op_entry; 
     446                    gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d: i is %d.\n" 
     447                                                  ,__func__ 
     448                                                  ,(int)thread->thread_id,i); 
    425449                    op = PINT_op_from_qentry(qentries[i]); 
    426450                    /* service the operation */ 
     451                    gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d: calling PINT_manager_service_op.\n" 
     452                                                  ,__func__ 
     453                                                  ,(int)thread->thread_id); 
    427454                    ret = PINT_manager_service_op( 
    428455                        manager, op, &service_time, &error); 
     
    433460                    } 
    434461 
     462                    gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d: calling PINT_manager_complete_op.\n" 
     463                                                  ,__func__ 
     464                                                  ,(int)thread->thread_id); 
    435465                    ret = PINT_manager_complete_op( 
    436466                        manager, op, error); 
     
    439469                        /* fatal if we can't complete an op */ 
    440470                        goto free_ops; 
     471                    } 
     472                    op_entry = id_gen_safe_lookup(op->id); 
     473                    if (op_entry) 
     474                    { 
     475                        id_gen_safe_unregister(op_entry->op.id); 
     476                        free(op_entry); 
     477                        op_entry = NULL; 
    441478                    } 
    442479                } 
     
    466503        /* lock the mutex again before checking the running field */ 
    467504        gen_mutex_lock(&thread->mutex); 
    468     } 
     505    }/*end while thread->running*/ 
    469506 
    470507    gen_mutex_unlock(&thread->mutex);