From: Stefan Sperling Subject: Re: tog: lock mutex on script error + blame view deallocation tweak To: Mark Jamsek Cc: Game of Trees Date: Sat, 15 Apr 2023 17:31:23 +0200 On Sat, Apr 15, 2023 at 11:02:42PM +1000, Mark Jamsek wrote: > I've attached a diff(1) patch of this because 'got diff' doesn't show > this change as cleanly. Looks reasonable and doesn't seem to break the blame view for me. ok > --- tog.c Sat Apr 15 22:29:33 2023 > +++ tog/tog.c Sat Apr 15 22:25:51 2023 > @@ -1707,8 +1707,10 @@ view_input(struct tog_view **new, int *done, struct to > > if (using_mock_io) { > err = tog_read_script_key(tog_io.f, &ch, done); > - if (err) > + if (err) { > + errcode = pthread_mutex_lock(&tog_mutex); > return err; > + } > } else if (view->count && --view->count) { > cbreak(); > nodelay(view->window, TRUE); > @@ -6997,12 +6999,6 @@ cmd_blame(int argc, char *argv[]) > if (error != NULL) > goto done; > > - view = view_open(0, 0, 0, 0, TOG_VIEW_BLAME); > - if (view == NULL) { > - error = got_error_from_errno("view_open"); > - goto done; > - } > - > error = got_object_open_as_commit(&commit, repo, commit_id); > if (error) > goto done; > @@ -7012,10 +7008,19 @@ cmd_blame(int argc, char *argv[]) > if (error) > goto done; > > + view = view_open(0, 0, 0, 0, TOG_VIEW_BLAME); > + if (view == NULL) { > + error = got_error_from_errno("view_open"); > + goto done; > + } > error = open_blame_view(view, link_target ? link_target : in_repo_path, > commit_id, repo); > - if (error) > + if (error != NULL) { > + if (view->close == NULL) > + close_blame_view(view); > + view_close(view); > goto done; > + } > if (worktree) { > /* Release work tree lock. */ > got_worktree_close(worktree); > @@ -7028,11 +7033,6 @@ done: > free(link_target); > free(cwd); > free(commit_id); > - if (error != NULL && view != NULL) { > - if (view->close == NULL) > - close_blame_view(view); > - view_close(view); > - } > if (commit) > got_object_commit_close(commit); > if (worktree) > > -- > Mark Jamsek > GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68 >