Just moved the looping code from main() into thread_main_loop().
This commit is contained in:
parent
bf82c863bc
commit
0d66719c5a
@ -1,3 +1,8 @@
|
|||||||
|
2002-04-08 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/thread.c (thread_main_loop): Moved the looping code into
|
||||||
|
this function from the main() function. Just a bit of clean up.
|
||||||
|
|
||||||
2002-04-07 Robert James Kaes <rjkaes@flarenet.com>
|
2002-04-07 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
* src/hashmap.c:
|
* src/hashmap.c:
|
||||||
|
41
src/thread.c
41
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
|
* Handles the creation/destruction of the various threads required for
|
||||||
* processing incoming connections.
|
* processing incoming connections.
|
||||||
@ -272,28 +272,37 @@ thread_main_loop(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* If there are not enough spare servers, create more */
|
while (1) {
|
||||||
SERVER_LOCK();
|
if (config.quit)
|
||||||
if (servers_waiting < thread_config.minspareservers) {
|
return;
|
||||||
SERVER_UNLOCK();
|
|
||||||
|
|
||||||
for (i = 0; i < thread_config.maxclients; i++) {
|
/* If there are not enough spare servers, create more */
|
||||||
if (thread_ptr[i].status == T_EMPTY) {
|
SERVER_LOCK();
|
||||||
pthread_create(&thread_ptr[i].tid, &thread_attr,
|
if (servers_waiting < thread_config.minspareservers) {
|
||||||
&thread_main, &thread_ptr[i]);
|
SERVER_UNLOCK();
|
||||||
thread_ptr[i].status = T_WAITING;
|
|
||||||
thread_ptr[i].connects = 0;
|
|
||||||
|
|
||||||
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,
|
SERVER_INC();
|
||||||
"Waiting servers is less than MinSpareServers. Creating new thread.");
|
|
||||||
|
|
||||||
break;
|
log_message(LOG_NOTICE,
|
||||||
|
"Waiting servers is less than MinSpareServers. Creating new thread.");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SERVER_UNLOCK();
|
||||||
|
|
||||||
|
sleep(5);
|
||||||
}
|
}
|
||||||
SERVER_UNLOCK();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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,
|
* The initialise routine. Basically sets up all the initial stuff (logfile,
|
||||||
* listening socket, config options, etc.) and then sits there and loops
|
* listening socket, config options, etc.) and then sits there and loops
|
||||||
@ -426,10 +426,8 @@ main(int argc, char **argv)
|
|||||||
* Start the main loop.
|
* Start the main loop.
|
||||||
*/
|
*/
|
||||||
log_message(LOG_INFO, "Starting main loop. Accepting connections.");
|
log_message(LOG_INFO, "Starting main loop. Accepting connections.");
|
||||||
do {
|
|
||||||
thread_main_loop();
|
thread_main_loop();
|
||||||
sleep(1);
|
|
||||||
} while (!config.quit);
|
|
||||||
|
|
||||||
log_message(LOG_INFO, "Shutting down.");
|
log_message(LOG_INFO, "Shutting down.");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user