commit 7226d972852afba286a7e46e9f3854667e1a816f from: Stefan Sperling date: Thu Feb 21 21:20:06 2019 UTC tog: better thread synchronization in scroll_down() commit - bc6aae89c2eb2254cc7aa4297cd98af69ff62ea9 commit + 7226d972852afba286a7e46e9f3854667e1a816f blob - 00edfdb7043b99a8442ce77fcf89ae1384e6e345 blob + e7f70edda49950f35b7b6ed51b3b93cf368a3c81 --- tog/tog.c +++ tog/tog.c @@ -1204,24 +1204,23 @@ scroll_down(struct commit_queue_entry **first_displaye do { pentry = TAILQ_NEXT(*last_displayed_entry, entry); - if (pentry == NULL) - *commits_needed = maxscroll + 20; - while (pentry == NULL) { - int errcode; - if (*log_complete) - break; - errcode = pthread_cond_signal(need_commits); - if (errcode) - return got_error_set_errno(errcode); - errcode = pthread_mutex_unlock(&tog_mutex); - if (errcode) - return got_error_set_errno(errcode); - pthread_yield(); - errcode = pthread_mutex_lock(&tog_mutex); - if (errcode) - return got_error_set_errno(errcode); - pentry = TAILQ_NEXT(*last_displayed_entry, entry); + if (pentry == NULL) { + *commits_needed = maxscroll + 20; + while (*commits_needed > 0) { + int errcode; + errcode = pthread_cond_signal(need_commits); + if (errcode) + return got_error_set_errno(errcode); + errcode = pthread_mutex_unlock(&tog_mutex); + if (errcode) + return got_error_set_errno(errcode); + pthread_yield(); + errcode = pthread_mutex_lock(&tog_mutex); + if (errcode) + return got_error_set_errno(errcode); + } } + pentry = TAILQ_NEXT(*last_displayed_entry, entry); if (pentry == NULL) break;