1
0
mirror of https://github.com/fumiama/simple-dict.git synced 2026-06-26 23:10:25 +08:00

try to fix sigsegv

This commit is contained in:
源文雨
2022-10-15 11:13:26 +08:00
parent 6237946c31
commit bec298d726

View File

@@ -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,12 +856,16 @@ 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 {
pthread_cond_init(&timer_pointer_of(p)->c, NULL);
pthread_mutex_init(&timer_pointer_of(p)->mc, NULL);
if (pthread_create(&timer->thread, &attr, (void *)&handle_accept, timer)) {
perror("Error creating thread"); perror("Error creating thread");
cleanup_thread(timer); cleanup_thread(timer);
putchar('\n'); putchar('\n');
} else puts("Thread created"); } else puts("Thread created");
} }
}
} }
#define argequ(i, arg) (*(uint16_t*)argv[i] == *(uint16_t*)(arg)) #define argequ(i, arg) (*(uint16_t*)argv[i] == *(uint16_t*)(arg))