X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/3fbfced7401cfcbb8006a9a6ce4add6b37a41a55..f6ffe40d1a2c985494e48dc2d36663ffde1e6044:/cache.c?ds=sidebyside diff --git a/cache.c b/cache.c index df1b4a3..2ccdc4e 100644 --- a/cache.c +++ b/cache.c @@ -61,8 +61,9 @@ static int open_slot(struct cache_slot *slot) if (bufz) bufkeylen = bufz - slot->buf; - slot->match = bufkeylen == slot->keylen && - !memcmp(slot->key, slot->buf, bufkeylen + 1); + if (slot->key) + slot->match = bufkeylen == slot->keylen && + !memcmp(slot->key, slot->buf, bufkeylen + 1); return 0; } @@ -223,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);