summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2002-04-08 21:35:10 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2002-04-08 21:35:10 +0000
commit0d66719c5afbc66d81ad4304b3c830c48379b0a8 (patch)
treeb2bb3dce5682381a1e5228053589610978287f9d /src
parentbf82c863bc58ee1e6b52d71e84c97fdd85bad5e4 (diff)
downloadtinyproxy-0d66719c5afbc66d81ad4304b3c830c48379b0a8.tar.gz
tinyproxy-0d66719c5afbc66d81ad4304b3c830c48379b0a8.zip
Just moved the looping code from main() into thread_main_loop().
Diffstat (limited to '')
-rw-r--r--src/thread.c41
-rw-r--r--src/tinyproxy.c8
2 files changed, 28 insertions, 21 deletions
diff --git a/src/thread.c b/src/thread.c
index 5b64caa..534ed8b 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -1,4 +1,4 @@
-/* $Id: thread.c,v 1.21 2002-01-25 00:01:45 rjkaes Exp $
+/* $Id: thread.c,v 1.22 2002-04-08 21:35:10 rjkaes Exp $
*
* Handles the creation/destruction of the various threads required for
* processing incoming connections.
@@ -272,28 +272,37 @@ thread_main_loop(void)
{
int i;
- /* If there are not enough spare servers, create more */
- SERVER_LOCK();
- if (servers_waiting < thread_config.minspareservers) {
- SERVER_UNLOCK();
+ while (1) {
+ if (config.quit)
+ return;
- for (i = 0; i < thread_config.maxclients; i++) {
- if (thread_ptr[i].status == T_EMPTY) {
- pthread_create(&thread_ptr[i].tid, &thread_attr,
- &thread_main, &thread_ptr[i]);
- thread_ptr[i].status = T_WAITING;
- thread_ptr[i].connects = 0;
+ /* If there are not enough spare servers, create more */
+ SERVER_LOCK();
+ if (servers_waiting < thread_config.minspareservers) {
+ SERVER_UNLOCK();
- SERVER_INC();
+ for (i = 0; i < thread_config.maxclients; i++) {
+ if (thread_ptr[i].status == T_EMPTY) {
+ pthread_create(&thread_ptr[i].tid,
+ &thread_attr,
+ &thread_main,
+ &thread_ptr[i]);
+ thread_ptr[i].status = T_WAITING;
+ thread_ptr[i].connects = 0;
- log_message(LOG_NOTICE,
- "Waiting servers is less than MinSpareServers. Creating new thread.");
+ SERVER_INC();
- break;
+ log_message(LOG_NOTICE,
+ "Waiting servers is less than MinSpareServers. Creating new thread.");
+
+ break;
+ }
}
}
+ SERVER_UNLOCK();
+
+ sleep(5);
}
- SERVER_UNLOCK();
}
/*
diff --git a/src/tinyproxy.c b/src/tinyproxy.c
index a243f1a..ff498b0 100644
--- a/src/tinyproxy.c
+++ b/src/tinyproxy.c
@@ -1,4 +1,4 @@
-/* $Id: tinyproxy.c,v 1.23 2002-04-07 21:36:39 rjkaes Exp $
+/* $Id: tinyproxy.c,v 1.24 2002-04-08 21:35:10 rjkaes Exp $
*
* The initialise routine. Basically sets up all the initial stuff (logfile,
* listening socket, config options, etc.) and then sits there and loops
@@ -426,10 +426,8 @@ main(int argc, char **argv)
* Start the main loop.
*/
log_message(LOG_INFO, "Starting main loop. Accepting connections.");
- do {
- thread_main_loop();
- sleep(1);
- } while (!config.quit);
+
+ thread_main_loop();
log_message(LOG_INFO, "Shutting down.");