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.
This commit is contained in:
Ben Noordhuis 2012-10-02 23:02:31 +02:00
parent 3977d1b36c
commit b37a0f5bb3

View File

@ -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)