Changeset 7826

Show
Ignore:
Timestamp:
06/16/09 16:08:34 (4 years ago)
Author:
sson
Message:

Used PINT_sm_frame(smcb->parent_smcb, 0) to refer parent smcbs in pipeline.sm.
Removed possible double free() in io.sm.

Location:
branches/as-branch/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/as-branch/src/common/misc/state-machine-fns.c

    r7822 r7826  
    309309        while (smcb->current_state->flag == SM_JUMP) 
    310310        { 
     311            gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, "%s: SM_JUMP\n", __func__); 
    311312            PINT_push_state(smcb, smcb->current_state); 
    312313            smcb->current_state = 
     
    657658        } 
    658659        frame_entry = qlist_entry(prev, struct PINT_frame_s, link); 
     660        gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, "returned frame=%p\n", 
     661                     frame_entry->frame); /* sson */ 
    659662        return frame_entry->frame; 
    660663    } 
  • branches/as-branch/src/server/io.sm

    r7823 r7826  
    5555            success => pvfs2_pipeline_sm; 
    5656        } 
    57         success => send_completion_ack; 
     57        success => cleanup_pipeline; 
     58    } 
     59 
     60    state cleanup_pipeline 
     61    { 
     62        run cleanup_pipeline_sm; 
     63        success => send_completion_ack; 
    5864        default => release; 
    5965    } 
     
    289295        pipeline_op->u.pipeline.seg_handle = seg_handle; 
    290296        pipeline_op->u.pipeline.id = id[i]; 
    291         pipeline_op->u.pipeline.parent = s_op; 
     297        //pipeline_op->u.pipeline.parent = s_op; 
    292298        pipeline_op->u.pipeline.hints = s_op->req->hints; 
    293299        pipeline_op->u.pipeline.tag = s_op->tag; 
     
    358364} 
    359365 
    360 /* 
    361  * Function: io_release() 
    362  * 
    363  * Params:   server_op *b,  
    364  *           job_status_s* js_p 
    365  * 
    366  * Pre:      we are done with all steps necessary to service 
    367  *           request 
    368  * 
    369  * Post:     operation has been released from the scheduler 
    370  * 
    371  * Returns:  int 
    372  * 
    373  * Synopsis: releases the operation from the scheduler 
    374  */ 
    375 static PINT_sm_action io_release( 
    376         struct PINT_smcb *smcb, job_status_s *js_p) 
     366static PINT_sm_action cleanup_pipeline_sm(struct PINT_smcb *smcb,  
     367                                          job_status_s *js_p) 
    377368{ 
    378369    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); 
    379     int ret = 0; 
    380     job_id_t i; 
    381  
    382     /* 
    383       tell the scheduler that we are done with this operation (if it 
    384       was scheduled in the first place) 
    385     */ 
    386     ret = job_req_sched_release( 
    387         s_op->scheduled_id, smcb, 0, js_p, &i, server_job_context); 
    388     return ret; 
    389 } 
    390  
    391 /* 
    392  * Function: io_cleanup() 
    393  * 
    394  * Params:   server_op *b,  
    395  *           job_status_s* js_p 
    396  * 
    397  * Pre:      all jobs done, simply need to clean up 
    398  * 
    399  * Post:     everything is free 
    400  * 
    401  * Returns:  int 
    402  * 
    403  * Synopsis: free up any buffers associated with the operation, 
    404  *           including any encoded or decoded protocol structures 
    405  */ 
    406 static PINT_sm_action io_cleanup( 
    407         struct PINT_smcb *smcb, job_status_s *js_p) 
    408 { 
    409     struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); 
    410     char status_string[64] = {0}; 
    411370    int i; 
    412371    struct PINT_server_op *pipeline_op; 
     
    414373    int remaining; 
    415374    PVFS_error tmp_err; 
    416  
    417     PVFS_strerror_r(s_op->resp.status, status_string, 64); 
    418     PINT_ACCESS_DEBUG(s_op, GOSSIP_ACCESS_DEBUG, "finish (%s)\n", status_string); 
    419  
    420     if (s_op->u.io.seg_handle) { 
    421         gossip_debug(GOSSIP_IO_DEBUG, "%s: freeing seg_handle\n", __func__); 
    422         PINT_segpool_destroy(s_op->u.io.seg_handle); 
    423     } 
    424  
    425     if(s_op->u.io.tmp_buffer) 
    426         free(s_op->u.io.tmp_buffer); /* FIXME */ 
    427375 
    428376    for(i=0; i<s_op->u.io.parallel_sms; i++) 
     
    447395    } 
    448396 
     397    js_p->error_code = 0; 
     398    return SM_ACTION_COMPLETE; 
     399} 
     400 
     401                                          
     402/* 
     403 * Function: io_release() 
     404 * 
     405 * Params:   server_op *b,  
     406 *           job_status_s* js_p 
     407 * 
     408 * Pre:      we are done with all steps necessary to service 
     409 *           request 
     410 * 
     411 * Post:     operation has been released from the scheduler 
     412 * 
     413 * Returns:  int 
     414 * 
     415 * Synopsis: releases the operation from the scheduler 
     416 */ 
     417static PINT_sm_action io_release( 
     418        struct PINT_smcb *smcb, job_status_s *js_p) 
     419{ 
     420    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); 
     421    int ret = 0; 
     422    job_id_t i; 
     423 
     424    /* 
     425      tell the scheduler that we are done with this operation (if it 
     426      was scheduled in the first place) 
     427    */ 
     428    ret = job_req_sched_release( 
     429        s_op->scheduled_id, smcb, 0, js_p, &i, server_job_context); 
     430    return ret; 
     431} 
     432 
     433/* 
     434 * Function: io_cleanup() 
     435 * 
     436 * Params:   server_op *b,  
     437 *           job_status_s* js_p 
     438 * 
     439 * Pre:      all jobs done, simply need to clean up 
     440 * 
     441 * Post:     everything is free 
     442 * 
     443 * Returns:  int 
     444 * 
     445 * Synopsis: free up any buffers associated with the operation, 
     446 *           including any encoded or decoded protocol structures 
     447 */ 
     448static PINT_sm_action io_cleanup( 
     449        struct PINT_smcb *smcb, job_status_s *js_p) 
     450{ 
     451    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); 
     452    char status_string[64] = {0}; 
     453 
     454    PVFS_strerror_r(s_op->resp.status, status_string, 64); 
     455    PINT_ACCESS_DEBUG(s_op, GOSSIP_ACCESS_DEBUG, "finish (%s)\n", status_string); 
     456 
     457    if (s_op->u.io.seg_handle) { 
     458        gossip_debug(GOSSIP_IO_DEBUG, "%s: freeing seg_handle\n", __func__); 
     459        PINT_segpool_destroy(s_op->u.io.seg_handle); 
     460    } 
     461#if 0 
     462    if(s_op->u.io.tmp_buffer) 
     463        free(s_op->u.io.tmp_buffer); /* FIXME */ 
     464#endif 
    449465    gen_mutex_destroy(&s_op->u.io.mutex); /* FIXME: */ 
    450466 
  • branches/as-branch/src/server/pipeline.sm

    r7825 r7826  
    124124 
    125125    gossip_debug(GOSSIP_IO_DEBUG, "smcb->base_frame=%d, frame_count=%d\n", smcb->base_frame, smcb->frame_count); 
    126     gossip_debug(GOSSIP_IO_DEBUG, "smcb=%p, smcb->parent_smcb=%p\n", smcb, smcb->parent_smcb); 
    127126    s_op->u.pipeline.buffer_used = 0; 
    128127    bytes = s_op->u.pipeline.buffer_size; 
     
    221220    job_id_t tmp_id; 
    222221    struct server_configuration_s *user_opts = get_server_config_struct(); 
    223     struct PINT_server_op *parent_s_op = s_op->u.pipeline.parent; 
     222    struct PINT_server_op *parent_s_op = PINT_sm_frame(smcb->parent_smcb, 0); 
    224223 
    225224    if(s_op->u.pipeline.segs == 0) { 
     
    310309{ 
    311310    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); 
    312     struct PINT_server_op *parent_s_op = s_op->u.pipeline.parent; 
     311    struct PINT_server_op *parent_s_op = PINT_sm_frame(smcb->parent_smcb, 0); 
    313312    js_p->error_code = 0; 
    314313    PVFS_size file_req_offset = parent_s_op->u.io.file_req_offset; 
     
    366365{ 
    367366    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); 
    368     struct PINT_server_op *parent_s_op = s_op->u.pipeline.parent; 
     367    struct PINT_server_op *parent_s_op = PINT_sm_frame(smcb->parent_smcb, 0); 
    369368    PINT_sm_msgpair_state *msg_p = NULL; 
    370369    struct server_configuration_s *user_opts = get_server_config_struct(); 
     
    504503{ 
    505504    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); 
    506     struct PINT_server_op *parent_s_op = s_op->u.pipeline.parent; 
     505    struct PINT_server_op *parent_s_op = PINT_sm_frame(smcb->parent_smcb, 0); 
    507506    js_p->error_code = 0; 
    508507 
     
    754753{ 
    755754    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); 
    756     struct PINT_server_op *parent_s_op = s_op->u.pipeline.parent; 
     755    struct PINT_server_op *parent_s_op = PINT_sm_frame(smcb->parent_smcb, 0); 
    757756    int ret, tmp_id; 
    758757    struct server_configuration_s *user_opts = get_server_config_struct(); 
     
    808807{ 
    809808    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); 
    810     struct PINT_server_op *parent_s_op = s_op->u.pipeline.parent; 
     809    struct PINT_server_op *parent_s_op = PINT_sm_frame(smcb->parent_smcb, 0); 
    811810    PINT_segpool_handle_t h = s_op->u.pipeline.seg_handle; 
    812811    js_p->error_code = 0; 
  • branches/as-branch/src/server/pvfs2-server.h

    r7821 r7826  
    380380    enum PVFS_io_type io_type; 
    381381 
    382     void *parent; 
    383382    char *buffer;  
    384383    PVFS_size buffer_size;