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

优化busy

This commit is contained in:
源文雨
2022-10-27 19:02:34 +08:00
parent dc8e37f9a4
commit a077f7b5a9

View File

@@ -796,19 +796,25 @@ static void handle_accept(void *p) {
#endif
}
CONV_END: puts("Conversation end");
if(timer_pointer_of(p)->accept_fd) {
close(timer_pointer_of(p)->accept_fd);
timer_pointer_of(p)->accept_fd = 0;
puts("Close accept");
}
close_dict(timer_pointer_of(p)->index);
setdicts[timer_pointer_of(p)->index].data[0] = 0;
pthread_mutex_lock(&timer_pointer_of(p)->mc);
pthread_rwlock_wrlock(&timer_pointer_of(p)->mb);
timer_pointer_of(p)->isbusy = 0;
pthread_mutex_lock(&timer_pointer_of(p)->mc);
pthread_rwlock_unlock(&timer_pointer_of(p)->mb);
puts("Set thread status to idle");
pthread_cond_wait(&timer_pointer_of(p)->c, &timer_pointer_of(p)->mc);
pthread_mutex_unlock(&timer_pointer_of(p)->mc);
puts("Thread wakeup");
}