diff --git a/main.c b/main.c index 1694d80..d0c2d16 100644 --- a/main.c +++ b/main.c @@ -81,7 +81,6 @@ int main(){ /* running through all once manually in order to get an as fast as possible first render on the screen */ - pthread_cond_signal(&cond_top); pthread_cond_signal(&cond_mid); pthread_cond_signal(&cond_lft); render_pass(); diff --git a/threading.c b/threading.c index e958c60..5fd26e6 100644 --- a/threading.c +++ b/threading.c @@ -61,7 +61,6 @@ void *thread_mid(){ pthread_mutex_lock(&mutex_mid); pthread_cond_wait(&cond_mid, &mutex_mid); - unsigned int local_status = status; if (global_path == NULL) { mid_dir.current_file = NULL; @@ -72,7 +71,7 @@ void *thread_mid(){ memcpy(path, global_path, strlen(global_path)+1); - if (local_status & STATUS_RELOAD_DIRECTORY) { + if (status & STATUS_RELOAD_DIRECTORY) { long index = mid_dir.current_file - mid_dir.file_list; tmp = mid_dir; @@ -102,6 +101,13 @@ void *thread_mid(){ mid_dir.current_file = mid_dir.file_list; } + pthread_mutex_unlock(&mutex_mid); + + pthread_cond_signal(&cond_top); + pthread_cond_signal(&cond_btm); + pthread_cond_signal(&cond_rgt); + + /* rendering */ pthread_mutex_lock(&mutex_render); werase(win_m); @@ -113,13 +119,8 @@ void *thread_mid(){ wnoutrefresh(win_m); pthread_mutex_unlock(&mutex_render); - pthread_cond_signal(&cond_top); - pthread_cond_signal(&cond_btm); - pthread_cond_signal(&cond_rgt); - pthread_mutex_unlock(&mutex_mid); - btm_status = local_status; unsigned long i; @@ -138,7 +139,6 @@ void *thread_lft(){ while(!(status & STATUS_QUIT_PROGRAM)){ pthread_mutex_lock(&mutex_lft); pthread_cond_wait(&cond_lft, &mutex_lft); - unsigned int local_status = status; if (global_path == NULL) { lft_dir.current_file = NULL; @@ -154,7 +154,7 @@ void *thread_lft(){ path[strrchr(path, '/')-path] = '\0'; path[0] = '/'; - if (local_status & STATUS_RELOAD_DIRECTORY) { + if (status & STATUS_RELOAD_DIRECTORY) { unsigned long i = 0; for (i = 0; i < lft_dir.file_count; i++) { free(lft_dir.file_list[i].file_name); @@ -317,10 +317,9 @@ void *thread_btm(){ while(!(status & STATUS_QUIT_PROGRAM)){ pthread_mutex_lock(&mutex_btm); pthread_cond_wait(&cond_btm, &mutex_btm); - unsigned int local_status = btm_status; - if (local_status & (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY)) { + if (status & (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY)) { /*{{{ parse storage info; the fold of shame*/ pthread_mutex_lock(&mutex_mid); unsigned long i;