Changeset 4406

Show
Ignore:
Timestamp:
10/03/06 10:02:50 (2 years ago)
Author:
morris
Message:

Must always take lock

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trackerd/trunk/trackerd/servers.c

    r4405 r4406  
    241241        wi_boolean_t            changed = false; 
    242242 
     243        wi_hash_wrlock(wt_servers); 
     244                 
    243245        if(wi_hash_count(wt_servers) > 0) { 
    244246                interval = wi_time_interval(); 
    245247 
    246                 wi_hash_wrlock(wt_servers); 
    247                  
    248248                enumerator = wi_array_data_enumerator(wi_hash_all_keys(wt_servers)); 
    249249                 
     
    262262                        } 
    263263                } 
    264                 
    265                 wi_hash_unlock(wt_servers); 
    266  
    267                 if(changed) { 
    268                        wi_lock_lock(wt_status_lock); 
    269                        wt_write_status(true); 
    270                        wi_lock_unlock(wt_status_lock); 
    271  
    272                         wt_write_servers(); 
    273                 } 
     264        } 
     265 
     266        wi_hash_unlock(wt_servers); 
     267 
     268        if(changed) { 
     269                wi_lock_lock(wt_status_lock); 
     270                wt_write_status(true); 
     271                wi_lock_unlock(wt_status_lock); 
     272 
     273                wt_write_servers(); 
    274274        } 
    275275} 
     
    305305        while((server = wi_enumerator_next_data(enumerator))) { 
    306306                if(wi_is_equal(server->ip, ip)) { 
    307                         value = server
     307                        value = wi_autorelease(wi_retain(server))
    308308 
    309309                        break; 
     
    322322         
    323323        wi_hash_rdlock(wt_servers); 
    324         server = wi_retain(wi_hash_data_for_key(wt_servers, key)); 
    325         wi_hash_unlock(wt_servers); 
    326          
    327         return wi_autorelease(server)
     324        server = wi_autorelease(wi_retain(wi_hash_data_for_key(wt_servers, key))); 
     325        wi_hash_unlock(wt_servers); 
     326         
     327        return server
    328328} 
    329329