fix: found a bug in ghttp

func_timer will kill teh whole child process and database needs to be loaded again

by zengli, need to be fixed
This commit is contained in:
bookug 2017-08-07 13:02:31 +08:00
parent 82b75a6c53
commit 745510772c
1 changed files with 4 additions and 0 deletions

View File

@ -145,6 +145,8 @@ int main(int argc, char *argv[])
srand(time(NULL)); srand(time(NULL));
while (true) { while (true) {
//NOTICE: here we use 2 processes, father process is used for monitor and control(like, restart)
//Child process is used to deal with web requests, can also has many threads
pid_t fpid = fork(); pid_t fpid = fork();
if (fpid == 0) { if (fpid == 0) {
@ -435,6 +437,8 @@ bool stop_thread(pthread_t _thread) {
return pthread_kill(_thread, SIGTERM) == 0; return pthread_kill(_thread, SIGTERM) == 0;
} }
//DEBUG+TODO: the whole process exits and need to reload the database
//(too slow: quit and restart)
void* func_timer(void* _args) { void* func_timer(void* _args) {
signal(SIGTERM, thread_sigterm_handler); signal(SIGTERM, thread_sigterm_handler);
sleep(Util::gserver_query_timeout); sleep(Util::gserver_query_timeout);