mirror of
https://github.com/fumiama/simple-dict.git
synced 2026-06-12 22:40:50 +08:00
try to fix sigsegv
This commit is contained in:
16
server.c
16
server.c
@@ -657,8 +657,6 @@ static void handle_pipe(int signo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handle_accept(void *p) {
|
static void handle_accept(void *p) {
|
||||||
pthread_cond_init(&timer_pointer_of(p)->c, NULL);
|
|
||||||
pthread_mutex_init(&timer_pointer_of(p)->mc, NULL);
|
|
||||||
pthread_cleanup_push((void*)&cleanup_thread, p);
|
pthread_cleanup_push((void*)&cleanup_thread, p);
|
||||||
puts("Handling accept...");
|
puts("Handling accept...");
|
||||||
while(1) {
|
while(1) {
|
||||||
@@ -858,11 +856,15 @@ static void accept_client(int fd) {
|
|||||||
pthread_cond_signal(&timer->c); // wakeup thread
|
pthread_cond_signal(&timer->c); // wakeup thread
|
||||||
pthread_mutex_unlock(&timer->mc);
|
pthread_mutex_unlock(&timer->mc);
|
||||||
puts("Pick thread from pool");
|
puts("Pick thread from pool");
|
||||||
} else if (pthread_create(&timer->thread, &attr, (void *)&handle_accept, timer)) {
|
} else {
|
||||||
perror("Error creating thread");
|
pthread_cond_init(&timer_pointer_of(p)->c, NULL);
|
||||||
cleanup_thread(timer);
|
pthread_mutex_init(&timer_pointer_of(p)->mc, NULL);
|
||||||
putchar('\n');
|
if (pthread_create(&timer->thread, &attr, (void *)&handle_accept, timer)) {
|
||||||
} else puts("Thread created");
|
perror("Error creating thread");
|
||||||
|
cleanup_thread(timer);
|
||||||
|
putchar('\n');
|
||||||
|
} else puts("Thread created");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user