Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Apple's threaded write()s bug

fixes test/simple/test-fs-sir-writes-alot.js on mac
  • Loading branch information...
commit ae91603dd7ef4ed31a24553dcc7a0c6451501f1e 1 parent 40b6197
@xk xk authored ry committed
Showing with 16 additions and 2 deletions.
  1. +16 −2 deps/libeio/eio.c
View
18 deps/libeio/eio.c
@@ -230,6 +230,10 @@ static xmutex_t reslock = X_MUTEX_INIT;
static xmutex_t reqlock = X_MUTEX_INIT;
static xcond_t reqwait = X_COND_INIT;
+#if defined (__APPLE__)
+static xmutex_t apple_bug_writelock = X_MUTEX_INIT;
+#endif
+
#if !HAVE_PREADWRITE
/*
* make our pread/pwrite emulation safe against themselves, but not against
@@ -1579,9 +1583,19 @@ static void eio_execute (etp_worker *self, eio_req *req)
req->result = req->offs >= 0
? pread (req->int1, req->ptr2, req->size, req->offs)
: read (req->int1, req->ptr2, req->size); break;
- case EIO_WRITE: req->result = req->offs >= 0
+ case EIO_WRITE:
+#if defined (__APPLE__)
+ pthread_mutex_lock (&apple_bug_writelock);
+#endif
+
+ req->result = req->offs >= 0
? pwrite (req->int1, req->ptr2, req->size, req->offs)
- : write (req->int1, req->ptr2, req->size); break;
+ : write (req->int1, req->ptr2, req->size);
+
+#if defined (__APPLE__)
+ pthread_mutex_unlock (&apple_bug_writelock);
+#endif
+ break;
case EIO_READAHEAD: req->result = readahead (req->int1, req->offs, req->size); break;
case EIO_SENDFILE: req->result = eio__sendfile (req->int1, req->int2, req->offs, req->size, self); break;
Please sign in to comment.
Something went wrong with that request. Please try again.