summaryrefslogtreecommitdiff
path: root/src/thread.c
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2001-09-06 19:00:47 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2001-09-06 19:00:47 +0000
commit445aaca53e0964f3243e4641b556c79493d8bb14 (patch)
tree254e98a270e3ac6f9f15dacf699b3cd2c66d6c12 /src/thread.c
parent05cc60042eeb76b9b92cff4397384eaef5819d80 (diff)
downloadtinyproxy-445aaca53e0964f3243e4641b556c79493d8bb14.tar.gz
tinyproxy-445aaca53e0964f3243e4641b556c79493d8bb14.zip
Initialzed the servers_waiting explictly. Added debugging code to find out
why the threads are not being closed.
Diffstat (limited to '')
-rw-r--r--src/thread.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/thread.c b/src/thread.c
index e84cf30..8245928 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -1,4 +1,4 @@
-/* $Id: thread.c,v 1.8 2001-08-28 04:33:21 rjkaes Exp $
+/* $Id: thread.c,v 1.9 2001-09-06 19:00:47 rjkaes Exp $
*
* Handles the creation/destruction of the various threads required for
* processing incoming connections.
@@ -118,7 +118,7 @@ static void *thread_main(void *arg)
return NULL;
}
- while (!config.quit) {
+ while (!config.quit) {
clilen = addrlen;
pthread_mutex_lock(&mlock);
connfd = accept(listenfd, cliaddr, &clilen);
@@ -182,9 +182,10 @@ int thread_pool_create(void)
for (i = 0; i < thread_config.startservers; i++) {
thread_ptr[i].status = T_WAITING;
- servers_waiting++;
pthread_create(&thread_ptr[i].tid, &thread_attr, &thread_main, &thread_ptr[i]);
}
+ servers_waiting = thread_config.startservers;
+
for (i = thread_config.startservers; i < thread_config.maxclients; i++) {
thread_ptr[i].status = T_EMPTY;
thread_ptr[i].connects = 0;
@@ -216,6 +217,7 @@ int thread_main_loop(void)
}
}
} else if (servers_waiting > thread_config.maxspareservers) {
+ DEBUG2("servers_waiting: %d MaxSpareServers: %d", servers_waiting, thread_config.maxspareservers);
for (i = 0; i < thread_config.maxclients; i++) {
if (thread_ptr[i].status == T_WAITING) {
pthread_join(thread_ptr[i].tid, NULL);
@@ -223,10 +225,13 @@ int thread_main_loop(void)
SERVER_DEC();
thread_ptr[i].status = T_EMPTY;
+ thread_ptr[i].connects = 0;
+
log_message(LOG_NOTICE, "Killed off a thread.");
break;
}
}
+ DEBUG1("finished killing threads");
}
return 0;