From b37a0f5bb3d0d6e1314d89eaabd2092c7548ba7d Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 2 Oct 2012 23:02:31 +0200 Subject: [PATCH] unix: fix small race in fs.c Don't return req->result after posting the work request. It's possible (if unlikely) for a worker thread to process the request before the main thread reaches the return statement. --- src/unix/fs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/unix/fs.c b/src/unix/fs.c index f60db587..84c51cba 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -84,13 +84,15 @@ #define POST \ do { \ - if ((cb) != NULL) \ + if ((cb) != NULL) { \ uv__work_submit((loop), &(req)->work_req, uv__fs_work, uv__fs_done); \ + return 0; \ + } \ else { \ uv__fs_work(&(req)->work_req); \ uv__fs_done(&(req)->work_req); \ + return (req)->result; \ } \ - return (req)->result; \ } \ while (0)