-
-
Save bnoordhuis/a05bffbf3b0a19e1dd20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/unix/fs.c b/src/unix/fs.c | |
index f0bf81a..97233ab 100644 | |
--- a/src/unix/fs.c | |
+++ b/src/unix/fs.c | |
@@ -41,6 +41,7 @@ | |
# include <sys/sendfile.h> | |
#elif defined(__APPLE__) || defined(__FreeBSD__) | |
# include <sys/socket.h> | |
+# include <sys/file.h> | |
# include <sys/uio.h> | |
#endif | |
@@ -436,8 +437,7 @@ static ssize_t uv__fs_write(uv_fs_t* req) { | |
* a dup(). | |
*/ | |
#if defined(__APPLE__) | |
- static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; | |
- pthread_mutex_lock(&lock); | |
+ flock(req->file, LOCK_EX); | |
#endif | |
if (req->off < 0) | |
@@ -446,7 +446,7 @@ static ssize_t uv__fs_write(uv_fs_t* req) { | |
r = pwrite(req->file, req->buf, req->len, req->off); | |
#if defined(__APPLE__) | |
- pthread_mutex_unlock(&lock); | |
+ flock(req->file, LOCK_UN); | |
#endif | |
return r; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment