diff options
author | Jorge Chamorro Bieling <jorge@jorgechamorro.com> | 2010-11-17 12:41:30 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-11-22 07:44:48 +0300 |
commit | 6aa92d5289996780834ebd5e9317718b3e55408c (patch) | |
tree | 1d958d5f1b7d54060aff6854b0daeb81a4a22133 /deps | |
parent | 7b2f5ab7f8b245774572c1d06aac9f6cdc2e14fe (diff) |
Apple's threaded write()s bug
fixes test/simple/test-fs-sir-writes-alot.js on mac
Diffstat (limited to 'deps')
-rw-r--r-- | deps/libeio/eio.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/deps/libeio/eio.c b/deps/libeio/eio.c index 0d30ce7920d..9ec8354d442 100644 --- a/deps/libeio/eio.c +++ b/deps/libeio/eio.c @@ -232,6 +232,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 @@ -1640,9 +1644,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; |