mirror of
https://github.com/fumiama/simple-dict.git
synced 2026-06-22 12:10:42 +08:00
优化退出
This commit is contained in:
4
server.c
4
server.c
@@ -576,6 +576,8 @@ static void handle_kill(int signo) {
|
|||||||
puts("Handle sigkill/sigterm");
|
puts("Handle sigkill/sigterm");
|
||||||
for(int i = 0; i < THREADCNT; i++) {
|
for(int i = 0; i < THREADCNT; i++) {
|
||||||
if(timers[i].thread) pthread_kill(timers[i].thread, SIGQUIT);
|
if(timers[i].thread) pthread_kill(timers[i].thread, SIGQUIT);
|
||||||
|
pthread_cond_destroy(&timers[i].tc);
|
||||||
|
pthread_mutex_destroy(&timers[i].tmc);
|
||||||
if(timers[i].timerthread) pthread_kill(timers[i].timerthread, SIGQUIT);
|
if(timers[i].timerthread) pthread_kill(timers[i].timerthread, SIGQUIT);
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@@ -644,6 +646,8 @@ static void handle_int(int signo) {
|
|||||||
puts("Keyboard interrupted");
|
puts("Keyboard interrupted");
|
||||||
for(int i = 0; i < THREADCNT; i++) {
|
for(int i = 0; i < THREADCNT; i++) {
|
||||||
if(timers[i].thread) pthread_kill(timers[i].thread, SIGQUIT);
|
if(timers[i].thread) pthread_kill(timers[i].thread, SIGQUIT);
|
||||||
|
pthread_cond_destroy(&timers[i].tc);
|
||||||
|
pthread_mutex_destroy(&timers[i].tmc);
|
||||||
if(timers[i].timerthread) pthread_kill(timers[i].timerthread, SIGQUIT);
|
if(timers[i].timerthread) pthread_kill(timers[i].timerthread, SIGQUIT);
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|||||||
Reference in New Issue
Block a user