Changeset 4568

Show
Ignore:
Timestamp:
02/10/07 01:46:47 (2 years ago)
Author:
morris
Message:

Use wi_pool_drain() instead of recreating pools

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wired/trunk/wired/commands.c

    r4508 r4568  
    231231 
    232232        while(client->state <= WD_CLIENT_STATE_LOGGED_IN) { 
    233                 if(!pool) 
    234                         pool = wi_pool_init(wi_pool_alloc()); 
    235                  
    236233                do { 
    237234                        state = wi_socket_wait(client->socket, 0.1); 
     
    268265                wd_parse_command(string); 
    269266                 
    270                 if(++i % 10 == 0) { 
    271                         wi_release(pool); 
    272                         pool = NULL; 
    273                 } 
     267                if(++i % 10 == 0) 
     268                        wi_pool_drain(pool); 
    274269        } 
    275270         
  • wired/trunk/wired/files.c

    r4508 r4568  
    675675static void wd_files_search_index(wi_string_t *query) { 
    676676        wd_client_t             *client = wd_client(); 
    677         wi_pool_t               *pool = NULL
     677        wi_pool_t               *pool
    678678        wi_file_t               *file; 
    679679        wi_string_t             *string; 
     
    699699        range.location = 0; 
    700700         
     701        pool = wi_pool_init(wi_pool_alloc()); 
     702 
    701703        while(true) { 
    702                 if(!pool) 
    703                         pool = wi_pool_init(wi_pool_alloc()); 
    704                  
    705704                string = wi_file_read_line(file); 
    706705                 
     
    720719                } 
    721720 
    722                 if(++i % 100 == 0) { 
    723                         wi_release(pool); 
    724                         pool = NULL; 
    725                 } 
     721                if(++i % 100 == 0) 
     722                        wi_pool_drain(pool); 
    726723        } 
    727724 
     
    884881         
    885882        while((p = wi_fts_read(fts))) { 
    886                 if(!pool) 
    887                         pool = wi_pool_init(wi_pool_alloc()); 
    888                  
    889883                /* skip item? */ 
    890884                action = wd_files_fts_action(p, &error); 
     
    995989                 
    996990next: 
    997                 if(++i % 100 == 0) { 
    998                         wi_release(pool); 
    999                         pool = NULL; 
    1000                 } 
     991                if(++i % 100 == 0) 
     992                        wi_pool_drain(pool); 
    1001993        } 
    1002994 
  • wired/trunk/wired/main.c

    r4509 r4568  
    253253                wd_trackers_register(true); 
    254254         
    255         wi_release(pool); 
    256         pool = wi_pool_init(wi_pool_alloc()); 
     255        /* clean up pool after startup */ 
     256        wi_pool_drain(pool); 
    257257 
    258258        /* enter the signal handling thread in the main thread */ 
     
    425425 
    426426        while(wd_running) { 
    427                 if(!pool) 
    428                         pool = wi_pool_init(wi_pool_alloc()); 
    429                  
    430427                signal = wd_wait_signals(); 
    431428                 
     
    475472                } 
    476473                 
    477                 if(++i % 10 == 0) { 
    478                         wi_release(pool); 
    479                         pool = NULL; 
    480                 } 
     474                if(++i % 10 == 0) 
     475                        wi_pool_drain(pool); 
    481476        } 
    482477         
  • wired/trunk/wired/server.c

    r4558 r4568  
    278278 
    279279        while(wd_running) { 
    280                 if(!pool) 
    281                         pool = wi_pool_init(wi_pool_alloc()); 
    282                  
    283280                /* accept new client */ 
    284281                socket = wi_socket_accept_multiple(wd_control_sockets, wd_control_socket_context, 30.0, &address); 
     
    309306 
    310307next: 
    311                 if(++i % 10 == 0) { 
    312                         wi_release(pool); 
    313                         pool = NULL; 
    314                 } 
     308                if(++i % 10 == 0) 
     309                        wi_pool_drain(pool); 
    315310        } 
    316311         
     
    332327 
    333328        while(wd_running) { 
    334                 if(!pool) 
    335                         pool = wi_pool_init(wi_pool_alloc()); 
    336                  
    337329                /* accept new connection */ 
    338330                socket = wi_socket_accept_multiple(wd_transfer_sockets, wd_transfer_socket_context, 30.0, &address); 
     
    382374 
    383375next: 
    384                 if(++i % 10 == 0) { 
    385                         wi_release(pool); 
    386                         pool = NULL; 
    387                 } 
     376                if(++i % 10 == 0) 
     377                        wi_pool_drain(pool); 
    388378        } 
    389379         
  • wired/trunk/wired/transfers.c

    r4508 r4568  
    628628 
    629629        while(transfer->state == WD_TRANSFER_RUNNING) { 
    630                 if(!pool) 
    631                         pool = wi_pool_init(wi_pool_alloc()); 
    632                  
    633630                /* read data */ 
    634631                bytes = read(fd, buffer, sizeof(buffer)); 
     
    691688                } 
    692689                 
    693                 if(++i % 100 == 0) { 
    694                         wi_release(pool); 
    695                         pool = NULL; 
    696                 } 
     690                if(++i % 100 == 0) 
     691                        wi_pool_drain(pool); 
    697692        } 
    698693 
     
    769764 
    770765        while(transfer->state == WD_TRANSFER_RUNNING) { 
    771                 if(!pool) 
    772                         pool = wi_pool_init(wi_pool_alloc()); 
    773                  
    774766                /* wait for timeout */ 
    775767                do { 
     
    832824                } 
    833825                 
    834                 if(++i % 100 == 0) { 
    835                         wi_release(pool); 
    836                         pool = NULL; 
    837                 } 
     826                if(++i % 100 == 0) 
     827                        wi_pool_drain(pool); 
    838828        } 
    839829