Changeset 852
- Timestamp:
- 07/21/07 21:33:41 (1 year ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/avl.c (modified) (9 diffs)
- cherokee/trunk/cherokee/avl.h (modified) (1 diff)
- cherokee/trunk/cherokee/balancer.c (modified) (1 diff)
- cherokee/trunk/cherokee/common.h (modified) (1 diff)
- cherokee/trunk/cherokee/dirs_table.c (modified) (1 diff)
- cherokee/trunk/cherokee/encoder_table.c (modified) (1 diff)
- cherokee/trunk/cherokee/handler_fastcgi.c (modified) (1 diff)
- cherokee/trunk/cherokee/iocache.c (modified) (4 diffs)
- cherokee/trunk/cherokee/plugin_loader.c (modified) (1 diff)
- cherokee/trunk/cherokee/regex.c (modified) (1 diff)
- cherokee/trunk/cherokee/server-protected.h (modified) (3 diffs)
- cherokee/trunk/cherokee/server.c (modified) (13 diffs)
- cherokee/trunk/cherokee/source.c (modified) (2 diffs)
- cherokee/trunk/cherokee/source.h (modified) (1 diff)
- cherokee/trunk/cherokee/source_interpreter.c (modified) (4 diffs)
- cherokee/trunk/cherokee/source_interpreter.h (modified) (1 diff)
- cherokee/trunk/cherokee/thread.c (modified) (22 diffs)
- cherokee/trunk/cherokee/thread.h (modified) (1 diff)
- cherokee/trunk/cherokee/util.c (modified) (1 diff)
- cherokee/trunk/cherokee/validator.c (modified) (5 diffs)
- cherokee/trunk/cherokee/validator.h (modified) (1 diff)
- cherokee/trunk/cherokee/validator_mysql.c (modified) (1 diff)
- cherokee/trunk/cherokee/validator_plain.c (modified) (2 diffs)
- cherokee/trunk/qa/054-ContentRange.py (modified) (1 diff)
- cherokee/trunk/qa/143-ContentRange-NoIO.py (added)
- cherokee/trunk/qa/144-ContentRange2-NoIO.py (added)
- cherokee/trunk/qa/145-ContentRange3-NoIO.py (added)
- cherokee/trunk/qa/146-ContentRange4-NoIO.py (added)
- cherokee/trunk/qa/147-ContentRange-Double-NoIO.py (added)
- cherokee/trunk/qa/148-ContentRange-Double2-NoIO.py (added)
- cherokee/trunk/qa/Makefile.am (modified) (1 diff)
- cherokee/trunk/qa/run-tests.py (modified) (2 diffs)
- cherokee/trunk/qa/util.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r851 r852 1 1 2007-07-21 Alvaro Lopez Ortega <alvaro@alobbs.com> 2 2 3 * cherokee/regex.c (cherokee_regex_table_free): Again, another 4 little tiny memory leak. The server leaked 41 bytes on each 5 reload. Fixed. 6 7 * cherokee/plugin_loader.c (cherokee_plugin_loader_mrproper): 8 Fixed nano memory leak - no more than 30 or 40 bytes. 9 10 * cherokee/avl.c, cherokee/avl.h, cherokee/dirs_table.c, 11 cherokee/encoder_table.c, cherokee/handler_fastcgi.c, 12 cherokee/iocache.c, cherokee/thread.h: Converted to use 13 cherokee_func_free() 14 15 * cherokee/common.h: Added new function type: cherokee_func_free. 16 17 * cherokee/source_interpreter.c, cherokee/source_interpreter.h, 18 cherokee/source.h, cherokee/source.c: Another little tiny memory 19 leak has been fixed here. The freed object wasn't calling its 20 predecessor destructor. 21 22 * cherokee/balancer.c (cherokee_balancer_mrproper): Memory leak 23 fixed. It wasn't freeing the source objects. 24 25 * cherokee/validator_plain.c (cherokee_validator_plain_check): 26 Rewritten from scratch. Now, it uses temporal buffers instead of a 27 fixed size temporal array - among other improvements. 28 29 * cherokee/validator.c (cherokee_validator_digest_check), 30 cherokee/validator_plain.c (cherokee_validator_plain_check), 31 cherokee/validator_mysql.c (cherokee_validator_mysql_check), 32 cherokee/validator.h: The battle against char * continues! Another 33 parameter char * converted to our sweet cherokee_buffer_t *. 34 35 * cherokee/validator.c (digest_HA2, 36 cherokee_validator_digest_check): Slightly optimized, a call to 37 cherokee_buffer_add_va() has been replaced. 38 39 * cherokee/validator.c (cherokee_validator_digest_response): Fixed 40 a 32 bytes memory leak. 41 42 * cherokee/iocache.c (cherokee_iocache_free): Now it uses 43 cherokee_avl_mrproper() instead of cherokee_avl_while() plus 44 free(). Besides the correctness, it fixed a memory leak. 45 46 * cherokee/avl.c: Clean up: avl_node_* static methods renamed. 47 Rewritten as _new/_free instead of _init/_mrproper. 48 (cherokee_avl_mrproper): Rewritten to use node_free(). 49 50 * cherokee/thread.c (process_active_connections), 51 cheroke/server.c, cherokee/server-protected.h: Reworked in order 52 to remove the call to cherokee_server_get_conns_num(). A thread 53 should never query or access other threads (and that's exactly 54 what method was doing). 55 56 * cherokee/thread.c (cherokee_thread_free): It wasn't freeing the 57 reusable connections. Fixed. 58 59 * qa/util.py (count_down): Refactored. There were two places in 60 which it needed count-downs. This is the common function. 61 62 * qa/run-tests.py (clean_up): Added a little pause. We should give 63 the server sometime to die gratefully between the SIGTERM and 64 SIGKILL signals. 65 66 * qa/Makefile.am, qa/143-ContentRange-NoIO.py, 67 qa/144-ContentRange2-NoIO.py, qa/145-ContentRange3-NoIO.py, 68 qa/146-ContentRange4-NoIO.py, qa/147-ContentRange-Double-NoIO.py, 69 qa/148-ContentRange-Double2-NoIO.py: Added 6 new test to check 70 partial file management without IOcache. 71 3 72 * cherokee/icons.c (cherokee_icons_free), 4 cherokee/avl.c (node_first): Protected. I was crashing when it was 5 NULL. 73 cherokee/avl.c (node_first): Protected against NULL pointers. 6 74 7 75 * cherokee/server.c (cherokee_server_handle_panic): PRINT_ERROR_S cherokee/trunk/cherokee/avl.c
r851 r852 51 51 */ 52 52 static ret_t 53 cherokee_avl_node_init (cherokee_avl_node_t *node, cherokee_buffer_t *key, void *value) 54 { 55 node->balance = 0; 56 node->left = NULL; 57 node->right = NULL; 58 node->left_child = false; 59 node->right_child = false; 60 node->value = value; 61 62 cherokee_buffer_init (&node->id); 63 cherokee_buffer_add_buffer (&node->id, key); 53 node_new (cherokee_avl_node_t **node, cherokee_buffer_t *key, void *value) 54 { 55 CHEROKEE_NEW_STRUCT (n, avl_node); 56 57 n->balance = 0; 58 n->left = NULL; 59 n->right = NULL; 60 n->left_child = false; 61 n->right_child = false; 62 n->value = value; 63 64 cherokee_buffer_init (&n->id); 65 cherokee_buffer_add_buffer (&n->id, key); 66 67 *node = n; 64 68 return ret_ok; 65 69 } 66 70 67 71 static ret_t 68 cherokee_avl_node_mrproper(cherokee_avl_node_t *node)72 node_free (cherokee_avl_node_t *node) 69 73 { 70 74 cherokee_buffer_mrproper (&node->id); 71 return ret_ok; 72 } 73 74 75 76 free (node); 77 return ret_ok; 78 } 75 79 76 80 /* Tree constructor / destructor … … 90 94 91 95 ret_t 92 cherokee_avl_mrproper (cherokee_avl_t *avl, cherokee_ avl_value_free_func_t free_func)96 cherokee_avl_mrproper (cherokee_avl_t *avl, cherokee_func_free_t free_func) 93 97 { 94 98 cherokee_avl_node_t *node; … … 103 107 next = node_next (node); 104 108 105 cherokee_buffer_mrproper (&node->id);106 109 if (free_func) 107 110 free_func (node->value); 108 109 free (node); 111 node_free (node); 112 110 113 node = next; 111 114 } … … 115 118 116 119 ret_t 117 cherokee_avl_free (cherokee_avl_t *avl, cherokee_ avl_value_free_func_t free_func)120 cherokee_avl_free (cherokee_avl_t *avl, cherokee_func_free_t free_func) 118 121 { 119 122 cherokee_avl_mrproper (avl, free_func); … … 136 139 return - (B->len - A->len); 137 140 else { 138 if ( unlikely(case_insensitive))141 if (case_insensitive) 139 142 return strcasecmp (A->buf, B->buf); 140 143 else … … 341 344 342 345 } else { 343 cherokee_avl_node_mrproper (child); 344 free (child); 346 node_free (child); 345 347 return; 346 348 } … … 381 383 cherokee_avl_add (cherokee_avl_t *avl, cherokee_buffer_t *key, void *value) 382 384 { 383 ret_t ret;384 CHEROKEE_NEW_STRUCT (n, avl_node);385 ret_t ret; 386 cherokee_avl_node_t *n = NULL; 385 387 386 388 /* Create the new AVL node 387 389 */ 388 ret = cherokee_avl_node_init (n, key, value);390 ret = node_new (&n, key, value); 389 391 if (unlikely (ret != ret_ok)) return ret; 390 392 … … 557 559 } 558 560 561 node_free (node); 559 562 return ret_ok; 560 563 } … … 771 774 } 772 775 773 cherokee/trunk/cherokee/avl.h
r838 r852 45 45 46 46 typedef ret_t (* cherokee_avl_while_func_t) (cherokee_buffer_t *key, void *value, void *param); 47 typedef void (* cherokee_avl_value_free_func_t) (void *param);47 //typedef void (* cherokee_avl_value_free_func_t) (void *param); 48 48 49 49 ret_t cherokee_avl_new (cherokee_avl_t **avl); 50 ret_t cherokee_avl_free (cherokee_avl_t *avl, cherokee_ avl_value_free_func_t free_func);50 ret_t cherokee_avl_free (cherokee_avl_t *avl, cherokee_func_free_t free_func); 51 51 52 52 ret_t cherokee_avl_init (cherokee_avl_t *avl); 53 ret_t cherokee_avl_mrproper (cherokee_avl_t *avl, cherokee_ avl_value_free_func_t free_func);53 ret_t cherokee_avl_mrproper (cherokee_avl_t *avl, cherokee_func_free_t free_func); 54 54 55 55 ret_t cherokee_avl_add (cherokee_avl_t *avl, cherokee_buffer_t *key, void *value); cherokee/trunk/cherokee/balancer.c
r597 r852 56 56 cherokee_balancer_mrproper (cherokee_balancer_t *balancer) 57 57 { 58 cuint_t i; 59 cherokee_source_t *source; 60 61 /* Free sources 62 */ 58 63 if (balancer->sources != NULL) { 64 for (i=0; i < balancer->sources_len; i++) { 65 source = balancer->sources[i]; 66 cherokee_source_free (source); 67 } 68 59 69 free (balancer->sources); 60 70 } cherokee/trunk/cherokee/common.h
r597 r852 69 69 typedef unsigned long long cullong_t; 70 70 71 typedef void (*cherokee_func_free_t) (void *); 71 72 72 73 CHEROKEE_END_DECLS cherokee/trunk/cherokee/dirs_table.c
r841 r852 49 49 { 50 50 return cherokee_avl_mrproper (AVL(pt), 51 (cherokee_ avl_value_free_func_t) cherokee_config_entry_free);51 (cherokee_func_free_t) cherokee_config_entry_free); 52 52 } 53 53 cherokee/trunk/cherokee/encoder_table.c
r841 r852 39 39 cherokee_encoder_table_mrproper (cherokee_encoder_table_t *et) 40 40 { 41 return cherokee_avl_mrproper (et, (cherokee_ avl_value_free_func_t)cherokee_encoder_table_entry_free);41 return cherokee_avl_mrproper (et, (cherokee_func_free_t)cherokee_encoder_table_entry_free); 42 42 } 43 43 cherokee/trunk/cherokee/handler_fastcgi.c
r841 r852 277 277 */ 278 278 if (CONN_THREAD(cnt)->fastcgi_servers == NULL) { 279 CONN_THREAD(cnt)->fastcgi_free_func = (cherokee_ avl_value_free_func_t) cherokee_fcgi_dispatcher_free;279 CONN_THREAD(cnt)->fastcgi_free_func = (cherokee_func_free_t) cherokee_fcgi_dispatcher_free; 280 280 cherokee_avl_new (&CONN_THREAD(cnt)->fastcgi_servers); 281 281 } cherokee/trunk/cherokee/iocache.c
r834 r852 165 165 } 166 166 167 static ret_t 168 iocache_entry_free (cherokee_iocache_entry_t *entry) 169 { 170 /* Free the object 171 */ 172 if (entry->mmaped != NULL) { 173 munmap (entry->mmaped, entry->mmaped_len); 174 175 entry->mmaped = NULL; 176 entry->mmaped_len = 0; 177 } 178 179 /* Free the entry object 180 */ 181 free (entry); 182 return ret_ok; 183 } 167 184 168 185 static ret_t … … 190 207 iocache_free_entry (cherokee_iocache_t *iocache, cherokee_iocache_entry_t *entry) 191 208 { 192 /* Free the object 193 */ 194 if (entry->mmaped != NULL) { 195 munmap (entry->mmaped, entry->mmaped_len); 196 197 entry->mmaped = NULL; 198 entry->mmaped_len = 0; 199 } 200 201 /* Free the entry object 202 */ 203 free (entry); 209 ret_t ret; 210 211 ret = iocache_entry_free (entry); 204 212 205 213 /* Update the obj counter … … 207 215 iocache->files_num--; 208 216 209 return ret _ok;217 return ret; 210 218 } 211 219 … … 422 430 423 431 424 static ret_t425 free_while_func (const char *key, void *value, void *param)426 {427 iocache_free_entry (IOCACHE(param), IOCACHE_ENTRY(value));428 return ret_ok;429 }430 431 432 432 static ret_t 433 433 cherokee_iocache_free (cherokee_iocache_t *iocache) 434 434 { 435 cherokee_avl_while (&iocache->files, 436 (cherokee_avl_while_func_t)free_while_func, 437 iocache, 438 NULL, NULL); 439 435 cherokee_avl_mrproper (&iocache->files, 436 (cherokee_func_free_t) iocache_entry_free); 440 437 CHEROKEE_MUTEX_DESTROY (&iocache->files_lock); 441 438 cherokee/trunk/cherokee/plugin_loader.c
r839 r852 208 208 { 209 209 cherokee_buffer_mrproper (&loader->module_dir); 210 cherokee_buffer_mrproper (&loader->deps_dir); 211 210 212 cherokee_avl_mrproper (&loader->table, free_entry); 211 213 return ret_ok; cherokee/trunk/cherokee/regex.c
r841 r852 58 58 59 59 cherokee_avl_mrproper (&table->cache, free); 60 61 free(table); 60 62 return ret_ok; 61 63 } cherokee/trunk/cherokee/server-protected.h
r811 r852 83 83 */ 84 84 cherokee_thread_t *main_thread; 85 intthread_num;85 cint_t thread_num; 86 86 cherokee_list_t thread_list; 87 intthread_policy;87 cint_t thread_policy; 88 88 89 89 /* Modules … … 123 123 cherokee_poll_type_t fdpoll_method; 124 124 125 /* Connection related .125 /* Connection related 126 126 */ 127 int max_conns; 128 int max_keepalive_conns; 127 cint_t conns_max; 128 cint_t conns_reuse_max; 129 cint_t conns_keepalive_max; 130 cuint_t conns_num_bogo; 129 131 130 132 /* Networking config … … 183 185 /* Performance 184 186 */ 185 int max_conn_reuse;186 187 187 188 /* PID cherokee/trunk/cherokee/server.c
r850 r852 153 153 n->fds_per_thread = -1; 154 154 n->system_fd_limit = -1; 155 n->max_conns = 0; 156 n->max_keepalive_conns = 0; 157 n->max_conn_reuse = -1; 155 156 n->conns_max = 0; 157 n->conns_reuse_max = -1; 158 n->conns_keepalive_max = 0; 159 n->conns_num_bogo = 0; 158 160 159 161 n->listen_queue = 1024; … … 642 644 /* File descriptor limit 643 645 */ 644 cherokee_buffer_add_va (&n, ", %d fds system limit, max. %d connections", srv->system_fd_limit, srv-> max_conns);646 cherokee_buffer_add_va (&n, ", %d fds system limit, max. %d connections", srv->system_fd_limit, srv->conns_max); 645 647 646 648 /* Threading stuff … … 747 749 /* Reset max. conns value 748 750 */ 749 srv->max_conns = 0; 750 srv->max_keepalive_conns = 0; 751 srv->conns_max = 0; 752 srv->conns_num_bogo = 0; 753 srv->conns_keepalive_max = 0; 751 754 752 755 /* Verify max_fds value … … 823 826 */ 824 827 conns_per_thread = fds_per_thread1 / 2; 825 srv-> max_conns+= conns_per_thread;828 srv->conns_max += conns_per_thread; 826 829 fds_per_thread1 += MAX_LISTEN_FDS; 827 830 … … 869 872 } 870 873 conns_per_thread = fds_per_thread1 / 2; 871 srv-> max_conns+= conns_per_thread;874 srv->conns_max += conns_per_thread; 872 875 fds_per_thread1 += MAX_LISTEN_FDS; 873 876 … … 895 898 * than conns_accept limit (95% - 99%) used for threads. 896 899 */ 897 srv-> max_keepalive_conns = srv->max_conns - (srv->max_conns/ 16);898 if (srv-> max_keepalive_conns + 6 > srv->max_conns)899 srv-> max_keepalive_conns = srv->max_conns- 6;900 srv->conns_keepalive_max = srv->conns_max - (srv->conns_max / 16); 901 if (srv->conns_keepalive_max + 6 > srv->conns_max) 902 srv->conns_keepalive_max = srv->conns_max - 6; 900 903 901 904 /* OK, return. … … 1115 1118 /* Check the number of reusable connections 1116 1119 */ 1117 if (srv-> max_conn_reuse== -1)1118 srv-> max_conn_reuse= DEFAULT_CONN_REUSE;1119 1120 if (srv-> max_conn_reuse> srv->max_fds)1121 srv-> max_conn_reuse= srv->max_fds;1120 if (srv->conns_reuse_max == -1) 1121 srv->conns_reuse_max = DEFAULT_CONN_REUSE; 1122 1123 if (srv->conns_reuse_max > srv->max_fds) 1124 srv->conns_reuse_max = srv->max_fds; 1122 1125 1123 1126 /* Get the passwd file entry before chroot … … 1132 1135 */ 1133 1136 if (! cherokee_buffer_is_empty (&srv->chroot)) { 1134 srv->chrooted = (chroot (srv->chroot.buf) == 0); 1137 re = chroot (srv->chroot.buf); 1138 srv->chrooted = (re == 0); 1135 1139 if (srv->chrooted == 0) { 1136 1140 char buferr[ERROR_MAX_BUFSIZE]; … … 1232 1236 1233 1237 return ret_ok; 1238 } 1239 1240 static void 1241 update_bogo_conns_num (cherokee_server_t *srv) 1242 { 1243 cherokee_server_get_conns_num (srv, &srv->conns_num_bogo); 1234 1244 } 1235 1245 … … 1264 1274 1265 1275 cherokee_buffer_clean (&srv->bogo_now_string); 1266 cherokee_buffer_add_va_fixed (&srv->bogo_now_string, 1267 "%s, %02d %s %d %02d:%02d:%02d GMT%c%d", 1268 cherokee_dtm_wday_name(srv->bogo_now_tm.tm_wday), 1269 srv->bogo_now_tm.tm_mday, 1270 cherokee_dtm_month_name(srv->bogo_now_tm.tm_mon), 1271 srv->bogo_now_tm.tm_year + 1900, 1272 srv->bogo_now_tm.tm_hour, 1273 srv->bogo_now_tm.tm_min, 1274 srv->bogo_now_tm.tm_sec, 1275 sign, offset); 1276 cherokee_buffer_add_va_fixed ( 1277 &srv->bogo_now_string, 1278 "%s, %02d %s %d %02d:%02d:%02d GMT%c%d", 1279 cherokee_dtm_wday_name(srv->bogo_now_tm.tm_wday), 1280 srv->bogo_now_tm.tm_mday, 1281 cherokee_dtm_month_name(srv->bogo_now_tm.tm_mon), 1282 srv->bogo_now_tm.tm_year + 1900, 1283 srv->bogo_now_tm.tm_hour, 1284 srv->bogo_now_tm.tm_min, 1285 srv->bogo_now_tm.tm_sec, 1286 sign, offset); 1276 1287 1277 1288 CHEROKEE_RWLOCK_UNLOCK (&srv->bogo_now_mutex); /* 2.- release */ … … 1308 1319 */ 1309 1320 update_bogo_now (srv); 1321 update_bogo_conns_num (srv); 1310 1322 1311 1323 /* Execute thread step. … … 1512 1524 1513 1525 } else if (equal_buf_str (&conf->key, "max_connection_reuse")) { 1514 srv-> max_conn_reuse= atoi (conf->val.buf);1526 srv->conns_reuse_max = atoi (conf->val.buf); 1515 1527 1516 1528 } else if (equal_buf_str (&conf->key, "ipv6")) { … … 1808 1820 */ 1809 1821 *num = conns_num; 1810 1811 1822 return ret_ok; 1812 1823 } cherokee/trunk/cherokee/source.c
r718 r852 46 46 47 47 src->port = -1; 48 src->free = NULL; 48 49 49 50 return ret_ok; … … 54 55 cherokee_source_mrproper (cherokee_source_t *src) 55 56 { 57 if (src->free) 58 src->free (src); 59 56 60 cherokee_buffer_mrproper (&src->original); 57 61 cherokee_buffer_mrproper (&src->unix_socket); cherokee/trunk/cherokee/source.h
r690 r852 39 39 40 40 typedef struct { 41 cherokee_list_t list;41 cherokee_list_t list; 42 42 43 cherokee_buffer_t original; 44 cherokee_buffer_t unix_socket; 45 cherokee_buffer_t host; 46 cint_t port; 43 cherokee_buffer_t original; 44 cherokee_buffer_t unix_socket; 45 cherokee_buffer_t host; 46 cint_t port; 47 48 cherokee_func_free_t free; 47 49 } cherokee_source_t; 48 50 cherokee/trunk/cherokee/source_interpreter.c
r597 r852 33 33 #define ENTRIES "source,src,interpreter" 34 34 35 static void interpreter_free (void *src); 36 35 37 36 38 ret_t … … 45 47 n->custom_env_len = 0; 46 48 49 SOURCE(n)->free = (cherokee_func_free_t)interpreter_free; 50 47 51 *src = n; 48 52 return ret_ok; … … 51 55 52 56 static void 53 free_custon_env (cherokee_source_interpreter_t *src) 54 { 55 cuint_t i; 57 free_custon_env (void *ptr) 58 { 59 cuint_t i; 60 cherokee_source_interpreter_t *src = ptr; 56 61 57 62 for (i=0; src->custom_env[i] != NULL; i++) { … … 63 68 64 69 65 ret_t 66 cherokee_source_interpreter_free (cherokee_source_interpreter_t *src) 67 { 68 cherokee_source_mrproper (SOURCE(src)); 70 static void 71 interpreter_free (void *ptr) 72 { 73 cherokee_source_interpreter_t *src = ptr; 74 75 /* Only frees its stuff, the rest will be freed by 76 * cherokee_source_t. 77 */ 69 78 cherokee_buffer_mrproper (&src->interpreter); 70 79 71 80 if (src->custom_env) 72 81 free_custon_env (src); 73 74 free (src);75 return ret_ok;76 82 } 77 83 cherokee/trunk/cherokee/source_interpreter.h
r597 r852 43 43 44 44 45 ret_t cherokee_source_interpreter_new (cherokee_source_interpreter_t **src);46 ret_t cherokee_source_interpreter_ free (cherokee_source_interpreter_t *src);45 ret_t cherokee_source_interpreter_new (cherokee_source_interpreter_t **src); 46 ret_t cherokee_source_interpreter_configure (cherokee_source_interpreter_t *src, cherokee_config_node_t *conf); 47 47 48 ret_t cherokee_source_interpreter_configure (cherokee_source_interpreter_t *src, cherokee_config_node_t *conf);49 48 ret_t cherokee_source_interpreter_add_env (cherokee_source_interpreter_t *src, char *env, char *val); 50 49 ret_t cherokee_source_interpreter_spawn (cherokee_source_interpreter_t *src); cherokee/trunk/cherokee/thread.c
r847 r852 365 365 /* Check the max connection reuse number 366 366 */ 367 if (thread->reuse_list_num >= THREAD_SRV(thread)-> max_conn_reuse) {367 if (thread->reuse_list_num >= THREAD_SRV(thread)->conns_reuse_max) { 368 368 return cherokee_connection_free (conn); 369 369 } … … 628 628 { 629 629 ret_t ret; 630 cuint_t srv_conns_num = 0;631 630 off_t len; 632 631 cherokee_list_t *i, *tmp; 633 cherokee_connection_t *conn = NULL; 634 cherokee_server_t *srv = SRV(thd->server); 635 636 /* Get total connection count. 637 * NOTE: when there are 2 or more threads, 638 * the real connection count can change while this thread 639 * is processing connections; as taking and releasing 640 * a lock might slow down things, we keep a private 641 * counter (srv_conns_num) that we decrease on every 642 * connection close; this should be enough for now. 643 */ 644 cherokee_server_get_conns_num (srv, &srv_conns_num); 632 cuint_t conns_freed = 0; 633 cherokee_connection_t *conn = NULL; 634 cherokee_server_t *srv = SRV(thd->server); 645 635 646 636 /* Process active connections … … 654 644 */ 655 645 if (conn->timeout < thd->bogo_now) { 656 srv_conns_num--;646 conns_freed++; 657 647 purge_closed_connection (thd, conn); 658 648 continue; … … 681 671 switch (num) { 682 672 case -1: 683 srv_conns_num--;673 conns_freed++; 684 674 purge_closed_connection(thd, conn); 685 675 continue; … … 708 698 case ret_eof: 709 699 case ret_error: 710 srv_conns_num--;700 conns_freed++; 711 701 purge_closed_connection (thd, conn); 712 702 continue; … … 714 704 default: 715 705 RET_UNKNOWN(ret); 716 srv_conns_num--;706 conns_freed++; 717 707 purge_closed_connection (thd, conn); 718 708 continue; … … 741 731 742 732 case ret_error: 743 srv_conns_num--;733 conns_freed++; 744 734 purge_closed_connection (thd, conn); 745 735 continue; … … 747 737 default: 748 738 RET_UNKNOWN(ret); 749 srv_conns_num--;739 conns_freed++; 750 740 purge_closed_connection (thd, conn); 751 741 break; … … 772 762 */ 773 763 if (!cherokee_post_got_all (&conn->post)) { 774 srv_conns_num--;764 conns_freed++; 775 765 purge_closed_connection (thd, conn); 776 766 continue; … … 781 771 782 772 case ret_error: 783 srv_conns_num--;773 conns_freed++; 784 774 purge_closed_connection (thd, conn); 785 775 continue; … … 787 777 default: 788 778 RET_UNKNOWN(ret); 789 srv_conns_num--;779 conns_freed++; 790 780 purge_closed_connection (thd, conn); 791 781 continue; … … 812 802 break; 813 803 case ret_error: 814 srv_conns_num--;804 conns_freed++; 815 805 purge_closed_connection (thd, conn); 816 806 continue; 817 807 default: 818 808 RET_UNKNOWN(ret); 819 srv_conns_num--;809 conns_freed++; 820 810 purge_closed_connection (thd, conn); 821 811 continue; … … 833 823 case ret_eof: 834 824 case ret_error: 835 srv_conns_num--;825 conns_freed++; 836 826 purge_closed_connection (thd, conn); 837 827 continue; 838 828 default: 839 829 RET_UNKNOWN(ret); 840 srv_conns_num--;830 conns_freed++; 841 831 purge_closed_connection (thd, conn); 842 832 continue; … … 863 853 continue; 864 854 case ret_error: 865 srv_conns_num--;855 conns_freed++; 866 856 purge_closed_connection (thd, conn); 867 857 continue; 868 858 default: 869 859 RET_UNKNOWN(ret); 870 srv_conns_num--;860 conns_freed++; 871 861 purge_closed_connection (thd, conn); 872 862 continue; … … 1091 1081 /* Server's "Keep-Alive" could be turned "Off" 1092 1082 */ 1093 if (conn->keepalive != 0 &&1094 (srv->keepalive == false||1095 srv_conns_num >= (cuint_t) srv->max_keepalive_conns)) {1096 conn->keepalive = 0;1083 if (conn->keepalive != 0) { 1084 if ((srv->keepalive == false) || 1085 ((srv->conns_num_bogo - conns_freed) >= srv->conns_keepalive_max)) 1086 conn->keepalive = 0; 1097 1087 } 1098 1088 …