commit - 93d213ec350c9e74725a35816e23de4da87ea8f7
commit + 33083b2ece357cee679ef84dea207a12302e4014
blob - da3af395b2dbac57ee04e516108f32c3ee9ba1cd
blob + 0ccc6a0f788f55d0c7f1bd60778f977402cfd4d8
--- tog/tog.c
+++ tog/tog.c
static const struct got_error *
check_cancelled(void *arg)
{
- if (tog_sigint_received || tog_sigpipe_received)
+ int rc, quit = 0;
+
+ if ((rc = pthread_mutex_lock(&tog_mutex)) != 0)
+ return got_error_set_errno(rc, "pthread_mutex_lock");
+ if (tog_sigint_received || tog_sigpipe_received || *((int *)arg))
+ quit = 1;
+ if ((rc = pthread_mutex_unlock(&tog_mutex)) != 0)
+ return got_error_set_errno(rc, "pthread_mutex_unlock");
+ if (quit)
return got_error(GOT_ERR_CANCELLED);
return NULL;
}
goto done;
err = got_worktree_status(wt, &paths, ta->repo, 0,
- check_local_changes, &wt_state, check_cancelled, NULL);
- if (err != NULL) {
- if (err->code != GOT_ERR_CANCELLED)
- goto done;
- err = NULL;
- }
+ check_local_changes, &wt_state, check_cancelled, ta->quit);
+ if (err != NULL)
+ goto done;
if (wt_state != 0) {
err = get_author(&wctx->wt_author, ta->repo, wt);
goto done;
}
err = tog_worktree_status(a);
- if (err != NULL)
+ if (err != NULL) {
+ if (err->code == GOT_ERR_CANCELLED)
+ err = NULL;
goto done;
+ }
errcode = pthread_mutex_lock(&tog_mutex);
if (errcode) {
err = got_error_set_errno(errcode,