From 3b485cc5422f800d142c7023295e82c0a1c10b19 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Mon, 24 Apr 2017 19:38:34 +0100 Subject: cache: flush stdio before restoring FDs As described in commit 2efb59e (ui-patch: Flush stdout after outputting data, 2014-06-11), we need to ensure that stdout is flushed before restoring the file descriptor when writing to the cache. It turns out that it's not just ui-patch that is affected by this but also raw diff which writes to stdout internally. Let's avoid risking more places doing this by ensuring that stdout is flushed after writing in fill_slot(). Signed-off-by: John Keeping --- cache.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cache.c') diff --git a/cache.c b/cache.c index 6736a01..2ccdc4e 100644 --- a/cache.c +++ b/cache.c @@ -224,6 +224,12 @@ static int fill_slot(struct cache_slot *slot) /* Generate cache content */ slot->fn(); + /* Make sure any buffered data is flushed to the file */ + if (fflush(stdout)) { + close(tmp); + return errno; + } + /* update stat info */ if (fstat(slot->lock_fd, &slot->cache_st)) { close(tmp); -- cgit v1.2.3-24-g4f1b From 67d0f870506e3bc3703ae3cb2cb00e19691ce967 Mon Sep 17 00:00:00 2001 From: Ville Skyttä Date: Sat, 14 Oct 2017 22:05:51 +0300 Subject: global: spelling fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ville Skyttä --- cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cache.c') diff --git a/cache.c b/cache.c index 2ccdc4e..0901e6e 100644 --- a/cache.c +++ b/cache.c @@ -318,7 +318,7 @@ static int process_slot(struct cache_slot *slot) /* If the cache slot does not exist (or its key doesn't match the * current key), lets try to create a new cache slot for this * request. If this fails (for whatever reason), lets just generate - * the content without caching it and fool the caller to belive + * the content without caching it and fool the caller to believe * everything worked out (but print a warning on stdout). */ -- cgit v1.2.3-24-g4f1b