summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2021-02-02 21:09:52 (GMT)
committerJohannes Schindelin <johannes.schindelin@gmx.de>2021-02-12 14:47:02 (GMT)
commit0d58fef58a6f382ba1d35f47a01cb55d8976335f (patch)
tree17f9a12a0f37445a0b1bfa4e88edfb768566b4b1 /run-command.c
parent684dd4c2b414bcf648505e74498a608f28de4592 (diff)
downloadgit-0d58fef58a6f382ba1d35f47a01cb55d8976335f.zip
git-0d58fef58a6f382ba1d35f47a01cb55d8976335f.tar.gz
git-0d58fef58a6f382ba1d35f47a01cb55d8976335f.tar.bz2
run-command: invalidate lstat cache after a command finished
In the previous commit, we intercepted calls to `rmdir()` to invalidate the lstat cache in the successful case, so that the lstat cache could not have the idea that a directory exists where there is none. The same situation can arise, of course, when a separate process is spawned (most notably, this is the case in `submodule_move_head()`). Obviously, we cannot know whether a directory was removed in that process, therefore we must invalidate the lstat cache afterwards. Note: in contrast to `lstat_cache_aware_rmdir()`, we invalidate the lstat cache even in case of an error: the process might have removed a directory and still have failed afterwards. Co-authored-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/run-command.c b/run-command.c
index a483d59..c5c4d36 100644
--- a/run-command.c
+++ b/run-command.c
@@ -953,6 +953,7 @@ int finish_command(struct child_process *cmd)
{
int ret = wait_or_whine(cmd->pid, cmd->argv[0], 0);
child_process_clear(cmd);
+ invalidate_lstat_cache();
return ret;
}
@@ -1239,13 +1240,19 @@ error:
int finish_async(struct async *async)
{
#ifdef NO_PTHREADS
- return wait_or_whine(async->pid, "child process", 0);
+ int ret = wait_or_whine(async->pid, "child process", 0);
+
+ invalidate_lstat_cache();
+
+ return ret;
#else
void *ret = (void *)(intptr_t)(-1);
if (pthread_join(async->tid, &ret))
error("pthread_join failed");
+ invalidate_lstat_cache();
return (int)(intptr_t)ret;
+
#endif
}