mirror of
https://github.com/fumiama/simple-dict.git
synced 2026-06-30 00:40:25 +08:00
fix mt
This commit is contained in:
5
server.c
5
server.c
@@ -626,6 +626,8 @@ static void accept_timer(void *p) {
|
|||||||
sigaddset(&mask, SIGPIPE); // 防止处理嵌套
|
sigaddset(&mask, SIGPIPE); // 防止处理嵌套
|
||||||
pthread_sigmask(SIG_BLOCK, &mask, NULL);
|
pthread_sigmask(SIG_BLOCK, &mask, NULL);
|
||||||
|
|
||||||
|
pthread_rwlock_unlock(&timer->mt);
|
||||||
|
|
||||||
sleep(MAXWAITSEC / 4);
|
sleep(MAXWAITSEC / 4);
|
||||||
pthread_rwlock_rdlock(&timer->mt);
|
pthread_rwlock_rdlock(&timer->mt);
|
||||||
thread = timer->thread;
|
thread = timer->thread;
|
||||||
@@ -710,6 +712,7 @@ static void handle_accept(void *p) {
|
|||||||
printf("accept ptr: %p\n", p);
|
printf("accept ptr: %p\n", p);
|
||||||
#endif
|
#endif
|
||||||
pthread_cleanup_push((void*)&cleanup_thread, p);
|
pthread_cleanup_push((void*)&cleanup_thread, p);
|
||||||
|
pthread_rwlock_unlock(&timer_pointer_of(p)->mt);
|
||||||
puts("Handling accept...");
|
puts("Handling accept...");
|
||||||
pthread_setspecific(pthread_key_index, (void*)((uintptr_t)timer_pointer_of(p)->index));
|
pthread_setspecific(pthread_key_index, (void*)((uintptr_t)timer_pointer_of(p)->index));
|
||||||
if(setjmp(jmp2convend[timer_pointer_of(p)->index])) goto CONV_END;
|
if(setjmp(jmp2convend[timer_pointer_of(p)->index])) goto CONV_END;
|
||||||
@@ -932,8 +935,10 @@ static void accept_client(int fd) {
|
|||||||
pthread_cond_init(&timer->tc, NULL);
|
pthread_cond_init(&timer->tc, NULL);
|
||||||
pthread_mutex_init(&timer->tmc, NULL);
|
pthread_mutex_init(&timer->tmc, NULL);
|
||||||
timer->hastimerslept = 0;
|
timer->hastimerslept = 0;
|
||||||
|
pthread_rwlock_wrlock(&timers[p].mt);
|
||||||
if (pthread_create(&timer->timerthread, &attr, (void *)&accept_timer, timer)) {
|
if (pthread_create(&timer->timerthread, &attr, (void *)&accept_timer, timer)) {
|
||||||
perror("Error creating timer thread");
|
perror("Error creating timer thread");
|
||||||
|
pthread_rwlock_unlock(&timers[p].mt);
|
||||||
cleanup_thread(timer);
|
cleanup_thread(timer);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user