From 32bf46e985a86e5c1dee9e4ed41c56ead89fa7ac Mon Sep 17 00:00:00 2001 From: Pavel Patrin Date: Sun, 4 Sep 2016 01:18:16 +0300 Subject: [PATCH] Fix reading inconsisntent data from spooler --- core/spooler.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/spooler.c b/core/spooler.c index 9e4b10ed64..9c485fc1b7 100755 --- a/core/spooler.c +++ b/core/spooler.c @@ -650,6 +650,12 @@ void spooler_manage_task(struct uwsgi_spooler *uspool, char *dir, char *task) { if (uwsgi_spooler_read_header(task, spool_fd, &uh)) return; + // access lstat second time after getting a lock + // first-time lstat could be dirty (for example between writes in master) + if (lstat(task, &sf_lstat)) { + return; + } + if (uwsgi_spooler_read_content(spool_fd, spool_buf, &body, &body_len, &uh, &sf_lstat)) { destroy_spool(dir, task); return;