Skip to content

Commit

Permalink
attempt to solve redraw related hangs
Browse files Browse the repository at this point in the history
a mutex didnt work out so now its spinlock guarded, hopefully this
solves the few rare cases of hanging mentioned in #31
  • Loading branch information
Ckath committed Jul 2, 2021
1 parent 7d61e5f commit de51dc9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ handle_chld()
static void
handle_redraw()
{
extern pthread_spinlock_t redraw_lock;
pthread_spin_lock(&redraw_lock);
sendwin();
srefresh();

Expand All @@ -71,6 +73,7 @@ handle_redraw()
cancel_preview();
refresh_layout();
}
pthread_spin_unlock(&redraw_lock);
}

static void
Expand Down Expand Up @@ -113,6 +116,8 @@ init()
init_colors();

/* init fuf */
extern pthread_spinlock_t redraw_lock; /* not the right place for this */
pthread_spin_init(&redraw_lock, PTHREAD_PROCESS_SHARED); /* , whatever */
handle_redraw();
start_load(load_items, display_load);
init_preview(load_preview);
Expand Down
1 change: 1 addition & 0 deletions inc/thr.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pthread_t preview_backup_thr;
pthread_cond_t run_preview = PTHREAD_COND_INITIALIZER;
pthread_mutex_t preview_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t preview_pid_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_spinlock_t redraw_lock;
pid_t preview_pid[2];
_Atomic bool items_loading = false;
_Atomic bool pn = false;
Expand Down

0 comments on commit de51dc9

Please sign in to comment.