mirror of
https://github.com/fumiama/simple-dict.git
synced 2026-07-01 01:10:24 +08:00
优化busy
This commit is contained in:
8
server.c
8
server.c
@@ -796,19 +796,25 @@ static void handle_accept(void *p) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CONV_END: puts("Conversation end");
|
CONV_END: puts("Conversation end");
|
||||||
|
|
||||||
if(timer_pointer_of(p)->accept_fd) {
|
if(timer_pointer_of(p)->accept_fd) {
|
||||||
close(timer_pointer_of(p)->accept_fd);
|
close(timer_pointer_of(p)->accept_fd);
|
||||||
timer_pointer_of(p)->accept_fd = 0;
|
timer_pointer_of(p)->accept_fd = 0;
|
||||||
puts("Close accept");
|
puts("Close accept");
|
||||||
}
|
}
|
||||||
|
|
||||||
close_dict(timer_pointer_of(p)->index);
|
close_dict(timer_pointer_of(p)->index);
|
||||||
setdicts[timer_pointer_of(p)->index].data[0] = 0;
|
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);
|
pthread_rwlock_wrlock(&timer_pointer_of(p)->mb);
|
||||||
timer_pointer_of(p)->isbusy = 0;
|
timer_pointer_of(p)->isbusy = 0;
|
||||||
pthread_mutex_lock(&timer_pointer_of(p)->mc);
|
|
||||||
pthread_rwlock_unlock(&timer_pointer_of(p)->mb);
|
pthread_rwlock_unlock(&timer_pointer_of(p)->mb);
|
||||||
|
|
||||||
puts("Set thread status to idle");
|
puts("Set thread status to idle");
|
||||||
pthread_cond_wait(&timer_pointer_of(p)->c, &timer_pointer_of(p)->mc);
|
pthread_cond_wait(&timer_pointer_of(p)->c, &timer_pointer_of(p)->mc);
|
||||||
|
|
||||||
pthread_mutex_unlock(&timer_pointer_of(p)->mc);
|
pthread_mutex_unlock(&timer_pointer_of(p)->mc);
|
||||||
puts("Thread wakeup");
|
puts("Thread wakeup");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user