manoj 99/02/15 23:10:29
Modified: pthreads/src/main http_main.c Log: Clean up a nasty memory leak. Now apache-apr uses a per-connection pool (ptrans) just like Apache 1.3. Previously, pchild was used, and in my tests, there was anywhere from 12-24k of memory lost per request. Revision Changes Path 1.29 +9 -5 apache-apr/pthreads/src/main/http_main.c Index: http_main.c =================================================================== RCS file: /home/cvs/apache-apr/pthreads/src/main/http_main.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -u -r1.28 -r1.29 --- http_main.c 1999/02/16 06:09:46 1.28 +++ http_main.c 1999/02/16 07:10:27 1.29 @@ -290,6 +290,7 @@ static pool *pperm; /* Pool for permananent stuff */ static pool *pconf; /* Pool for config stuff */ +static pool *ptrans; /* Pool for per-transaction stuff */ static pool *ptemp; /* Pool for temporart config stuff */ static pool *pcommands; /* Pool for -C and -c switches */ @@ -1666,7 +1667,7 @@ /* ZZZ doesn't really make sense in a threaded server. */ } -static void process_socket(pool *ptrans, struct sockaddr *sa_client, int csd, int my_child_num, int my_thread_num) +static void process_socket(pool *p, struct sockaddr *sa_client, int csd, int my_child_num, int my_thread_num) { struct sockaddr sa_server; /* ZZZZ */ size_t len = sizeof(struct sockaddr); @@ -1674,7 +1675,7 @@ request_rec *r; conn_rec *current_conn; - ap_note_cleanups_for_fd(ptrans, csd); + ap_note_cleanups_for_fd(p, csd); /* ZZZ change to AP func */ if (getsockname(csd, &sa_server, &len) < 0) { @@ -1683,10 +1684,10 @@ } (void) ap_update_child_status(my_child_num, my_thread_num, SERVER_BUSY_READ, (request_rec *) NULL); - conn_io = ap_bcreate(ptrans, B_RDWR | B_SOCKET); + conn_io = ap_bcreate(p, B_RDWR | B_SOCKET); ap_bpushfd(conn_io, csd, csd); - current_conn = new_connection(ptrans, server_conf, conn_io, + current_conn = new_connection(p, server_conf, conn_io, (const struct sockaddr_in *) sa_client, (const struct sockaddr_in *) &sa_server, my_child_num, my_thread_num); @@ -1793,15 +1794,18 @@ free(ti); + ptrans = ap_make_sub_pool(pconf); while (0 < requests_this_child) { (void) ap_update_child_status(my_pid, my_tid, SERVER_READY, (request_rec *) NULL); csd = queue_pop(&csd_queue, &sa_client); if (csd >= 0) { - process_socket(pchild, &sa_client, csd, my_pid, my_tid); + process_socket(ptrans, &sa_client, csd, my_pid, my_tid); } + ap_clear_pool(ptrans); } + ap_destroy_pool(ptrans); ap_update_child_status(my_pid, my_tid, SERVER_DEAD, (request_rec *) NULL); pthread_once(&firstcall, graceful_killer);