Changeset 9190

Show
Ignore:
Timestamp:
02/10/12 12:06:33 (16 months ago)
Author:
denton
Message:

Calling daemon with parameters (0,0).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/apps/ucache/ucached.c

    r9178 r9190  
    204204    int rc = 0; 
    205205 
    206     int old_locks_present = 0; 
     206    int old_aux_present = 0; 
    207207 
    208208    /* attempt setup of shmem region for locks (inlcude SYSV later? */ 
    209209    int id = SHM_ID1; 
    210210    key_t key = ftok(KEY_FILE, id); 
    211     size_t size = LOCKS_SIZE; 
     211    size_t size = UCACHE_AUX_SIZE; 
    212212    int shmflg = SVSHM_MODE; 
    213     int lock_shmid = shmget(key, size, shmflg); 
    214  
    215     if(lock_shmid == -1) 
     213    int aux_shmid = shmget(key, size, shmflg); 
     214 
     215    if(aux_shmid == -1) 
    216216    { 
    217217        gossip_debug(GOSSIP_UCACHED_DEBUG, 
    218             "INFO: shmget on lock_shmid returned -1 on first try\n"); 
    219  
    220         /* Shared memory segment used for locks was not previosly created,  
     218            "INFO: shmget on aux_shmid returned -1 on first try\n"); 
     219 
     220        /* Shared memory segment used for aux data was not previosly created,  
    221221         * so create it. 
    222222         */ 
    223223        shmflg = shmflg | IPC_CREAT | IPC_EXCL; 
    224         lock_shmid = shmget(key, size, shmflg); 
    225         if(lock_shmid == -1) 
     224        aux_shmid = shmget(key, size, shmflg); 
     225        if(aux_shmid == -1) 
    226226        { 
    227227            gossip_debug(GOSSIP_UCACHED_DEBUG, 
    228228                "ERROR: shmget (IPC_CREATE, IPC_EXCL)" 
    229                 " on lock_shmid returned -1\n"); 
     229                " on aux_shmid returned -1\n"); 
    230230            /* Couldn't create the required segment */ 
    231231            return -1; 
     
    235235            gossip_debug(GOSSIP_UCACHED_DEBUG, 
    236236            "INFO: shmget (using IPC_CREATE, IPC_EXCL)" 
    237                 " on lock_shmid returned shmid = %d\n", lock_shmid); 
    238  
    239             /* Attach to shmem and initialize all the locks */ 
     237                " on aux_shmid returned shmid = %d\n", aux_shmid); 
     238 
     239            /* Attach to shmem and initialize all the aux struct */ 
    240240            shmflg = 0; 
    241             /* ucache_locks is defined in src/client/usrint/ucache.h */ 
    242             ucache_locks = shmat(lock_shmid, NULL, shmflg); 
    243             if (!ucache_locks) 
     241            /* ucache_aux is defined in src/client/usrint/ucache.h */ 
     242            ucache_aux = shmat(aux_shmid, NULL, shmflg); 
     243            if (!ucache_aux) 
    244244            { 
    245245                gossip_debug(GOSSIP_UCACHED_DEBUG, 
    246                     "ERROR: shmat on lock_shmid returned NULL"); 
     246                    "ERROR: shmat on aux_shmid returned NULL"); 
    247247                return -1; 
    248248            } 
    249249 
     250            ucache_locks = ucache_aux->ucache_locks; 
     251 
    250252            int i; 
    251             /* Initialize Block Level Locks */ 
     253            /* Initialize Shared Block Level Locks */ 
    252254            for(i = 0; i < (BLOCKS_IN_CACHE + 1); i++) 
    253255            { 
     
    265267    { 
    266268        gossip_debug(GOSSIP_UCACHED_DEBUG, 
    267             "INFO: first shmget on lock_shmid found segment" 
    268             ": shmid = %d\n", lock_shmid); 
    269         old_locks_present = 1; 
    270         /* Shmem for locks was already created, so just attach to it */ 
     269            "INFO: first shmget on aux_shmid found segment" 
     270            ": shmid = %d\n", aux_shmid); 
     271        old_aux_present = 1; 
     272        /* Shmem for ucache_aux was already created, so just attach to it */ 
    271273        shmflg = 0; 
    272         ucache_locks = shmat(lock_shmid, NULL, shmflg); 
    273         if (!ucache_locks) 
    274         { 
    275             gossip_debug(GOSSIP_UCACHED_DEBUG, 
    276                 "ERROR: shmat on lock_shmid returned NULL\n"); 
     274        ucache_aux = shmat(aux_shmid, NULL, shmflg); 
     275        if (!ucache_aux) 
     276        { 
     277            gossip_debug(GOSSIP_UCACHED_DEBUG, 
     278                "ERROR: shmat on aux_shmid returned NULL\n"); 
    277279            return -1; 
    278280        }     
     
    290292    gossip_debug(GOSSIP_UCACHED_DEBUG, 
    291293        "INFO: lock segment successfully retrieved and global lock locked.\n"); 
     294 
     295    /* Set and zero out global ucache stats struct */ 
     296    ucache_stats = &(ucache_aux->ucache_stats); 
     297    *ucache_stats = (struct ucache_stats_s){ 0, 0, 0, 0, 0 }; 
    292298 
    293299    /* Try to get/create the shmem required for the ucache */ 
     
    304310 
    305311        /* Remember if there was an old lock region detected */ 
    306         if(old_locks_present) 
    307         { 
    308             gossip_debug(GOSSIP_UCACHED_DEBUG, 
    309                 "INFO: old locks discovered, attempting destruction of old"  
     312        if(old_aux_present) 
     313        { 
     314            gossip_debug(GOSSIP_UCACHED_DEBUG, 
     315                "INFO: old ucache_aux found, attempting destruction of old" 
    310316                " locks and starting\n"); 
    311317 
    312             /* Destroy old lock region and start function over */ 
    313             rc = shmctl(lock_shmid, IPC_RMID, (struct shmid_ds *) NULL); 
     318            /* Destroy old aux region and start function over */ 
     319            rc = shmctl(aux_shmid, IPC_RMID, (struct shmid_ds *) NULL); 
    314320 
    315321            /* Let this child process exit, since exiting is required to get 
     
    570576 
    571577    /* Daemonize! */ 
    572     rc = daemon(1, 1); 
     578    rc = daemon(0, 0); 
    573579 
    574580    if(rc != 0)