Changeset 9301

Show
Ignore:
Timestamp:
04/30/12 11:16:05 (13 months ago)
Author:
denton
Message:

Updated PINT_acache_update to only calloc memory for the acache payload when necessary. Removed conditionals that were incorrectly placed.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/acache_improvement/src/client/sysint/acache.c

    r9300 r9301  
    386386    */ 
    387387   
    388     /* lookup non-static components */ 
     388    /* lookup */ 
    389389    ret = PINT_tcache_lookup(acache, &refn, &tmp_entry, &status); 
    390390    if(ret < 0 || status != 0) 
     
    412412    current_time_msecs += current_time.tv_usec / 1000; 
    413413 
    414     /* Check to see if either the security or dynamic attrs have expired. */ 
    415     if((current_time_msecs - tmp_payload->msecs_security) >  
    416         SECURITY_ACACHE_DEFAULT_TIMEOUT_MSECS) 
    417     { 
    418         security_expired = 1; 
    419  
    420         /* Fetch/update security attr */ 
    421  
    422     } 
    423  
    424     if((current_time_msecs - tmp_payload->msecs_dynamic) > 
    425         DYNAMIC_ACACHE_DEFAULT_TIMEOUT_MSECS) 
    426     { 
    427         dynamic_attrs_expired = 1; 
    428  
    429         /* Fetch/update dynamic attrs */ 
    430  
    431     } 
     414    /* Reset Dynamic attrs timestamp since it was hit regardless of timeout. */ 
     415    tmp_payload->msecs_dynamic = current_time_msecs; 
    432416 
    433417 
     
    656640    uint32_t old_mask; 
    657641    int ret = -1; 
     642    /* Storage of current time */ 
     643    struct timeval current_time = { 0, 0}; 
     644    uint64_t current_time_msecs = 0; 
    658645 
    659646    /* skip out immediately if the cache is disabled */ 
     
    736723    if(size || (attr && (attr->mask & (~(PVFS_STATIC_ATTR_MASK))))) 
    737724    { 
    738         tmp_payload =  
    739             (struct acache_payload*)calloc(1, sizeof(*tmp_payload)); 
     725        /* Allocate memory for acache payload if not previously done. */ 
    740726        if(!tmp_payload) 
    741727        { 
    742             ret = -PVFS_ENOMEM; 
    743             goto err; 
    744         } 
    745         tmp_payload->refn = refn; 
     728            tmp_payload =  
     729                (struct acache_payload*)calloc(1, sizeof(*tmp_payload)); 
     730            if(!tmp_payload) 
     731            { 
     732                ret = -PVFS_ENOMEM; 
     733                goto err; 
     734            } 
     735            tmp_payload->refn = refn; 
     736        }         
     737 
    746738        tmp_payload->attr_status = -PVFS_ETIME; 
    747739        tmp_payload->size_status = -PVFS_ETIME; 
     
    770762  
    771763    } 
    772     
     764 
     765    /* Get the time of day and convert to millisecond resolution. */ 
     766    gettimeofday(&current_time, NULL); 
     767    current_time_msecs = current_time.tv_sec * 1000; 
     768    current_time_msecs += current_time.tv_usec / 1000; 
     769 
     770    /* See if the security attr timestamp has been set, if not then set it. */ 
     771    if(!tmp_payload->msecs_security) 
     772    { 
     773        tmp_payload->msecs_security = current_time_msecs; 
     774    } 
     775    /* Update the dynamic attrs' timestamp regardless of if it has already been set. */ 
     776    tmp_payload->msecs_dynamic = current_time_msecs; 
     777 
    773778#if 0 
    774779    gossip_debug(GOSSIP_ACACHE_DEBUG, "acache: update(): attr_status=%d, size_status=%d\n",