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

try to fix 死锁

This commit is contained in:
源文雨
2022-05-04 18:48:29 +08:00
parent 533510eb16
commit 0f97db5803
2 changed files with 2 additions and 2 deletions

2
dict.h
View File

@@ -95,7 +95,7 @@ static int init_dict(char* file_path, pthread_rwlock_t* mu) {
static FILE* open_dict(uint8_t lock_type, uint32_t index, pthread_rwlock_t* mu) {
if(lock_type & DICT_LOCK_EX) {
if(pthread_rwlock_trywrlock(mu)) {
if(pthread_rwlock_wrlock(mu)) {
puts("Open dict: Writelock busy");
return NULL;
}

View File

@@ -435,7 +435,7 @@ static void handle_int(int signo) {
}
static void handle_pipe(int signo) {
fprintf(stderr, "Pipe error: %d\n", signo);
puts("Pipe error, exit thread...");
pthread_exit(NULL);
}