Added code to check for "errors" from the accept call in thread_main() and
also a new thread_kill_threads() function which should cancel all threads when the main thread is being closed.
This commit is contained in:
parent
388920bc53
commit
1819c0f818
@ -1,3 +1,8 @@
|
|||||||
|
2002-01-13 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/thread.c (thread_kill_threads): Added a function to
|
||||||
|
explictly go through all the active threads and kill them.
|
||||||
|
|
||||||
2002-01-07 Robert James Kaes <rjkaes@flarenet.com>
|
2002-01-07 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
* src/thread.c (thread_main): Added code to check if tinyproxy is
|
* src/thread.c (thread_main): Added code to check if tinyproxy is
|
||||||
|
24
src/thread.c
24
src/thread.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: thread.c,v 1.20 2002-01-08 02:02:25 rjkaes Exp $
|
/* $Id: thread.c,v 1.21 2002-01-25 00:01:45 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.
|
||||||
@ -144,6 +144,14 @@ thread_main(void *arg)
|
|||||||
* Make sure no error occurred...
|
* Make sure no error occurred...
|
||||||
*/
|
*/
|
||||||
if (connfd < 0) {
|
if (connfd < 0) {
|
||||||
|
/*
|
||||||
|
* Accept could return an "error" if it was
|
||||||
|
* interrupted by a signal (like when the program
|
||||||
|
* should be killed. :)
|
||||||
|
*/
|
||||||
|
if (config.quit)
|
||||||
|
break;
|
||||||
|
|
||||||
log_message(LOG_ERR, "Accept returned an error (%s) ... retrying.", strerror(errno));
|
log_message(LOG_ERR, "Accept returned an error (%s) ... retrying.", strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -288,6 +296,20 @@ thread_main_loop(void)
|
|||||||
SERVER_UNLOCK();
|
SERVER_UNLOCK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Go through all the non-empty threads and cancel them.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
thread_kill_threads(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < thread_config.maxclients; i++) {
|
||||||
|
if (thread_ptr[i].status != T_EMPTY)
|
||||||
|
pthread_cancel(thread_ptr[i].tid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
thread_listening_sock(uint16_t port)
|
thread_listening_sock(uint16_t port)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: thread.h,v 1.3 2001-09-07 04:20:04 rjkaes Exp $
|
/* $Id: thread.h,v 1.4 2002-01-25 00:01:45 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'thread.c' for more information.
|
* See 'thread.c' for more information.
|
||||||
*
|
*
|
||||||
@ -30,6 +30,7 @@ extern short int thread_pool_create(void);
|
|||||||
extern int thread_listening_sock(uint16_t port);
|
extern int thread_listening_sock(uint16_t port);
|
||||||
extern void thread_close_sock(void);
|
extern void thread_close_sock(void);
|
||||||
extern void thread_main_loop(void);
|
extern void thread_main_loop(void);
|
||||||
|
extern void thread_kill_threads(void);
|
||||||
|
|
||||||
extern short int thread_configure(thread_config_t type, unsigned int val);
|
extern short int thread_configure(thread_config_t type, unsigned int val);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tinyproxy.c,v 1.21 2001-12-23 22:00:36 rjkaes Exp $
|
/* $Id: tinyproxy.c,v 1.22 2002-01-25 00:01:45 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
|
||||||
@ -432,6 +432,8 @@ main(int argc, char **argv)
|
|||||||
} while (!config.quit);
|
} while (!config.quit);
|
||||||
|
|
||||||
log_message(LOG_INFO, "Shutting down.");
|
log_message(LOG_INFO, "Shutting down.");
|
||||||
|
|
||||||
|
thread_kill_threads();
|
||||||
thread_close_sock();
|
thread_close_sock();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user