darwin: abort() if (un)locking fs mutex fails

The pthread_mutex_lock() and pthread_mutex_unlock() calls logically
cannot fail in uv__fs_write() but let's check the return value anyway:
cosmic rays and memory corruption do happen.

PR-URL: https://github.com/libuv/libuv/pull/603
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
Ben Noordhuis 2015-11-02 01:00:48 +01:00
parent f3216246a2
commit a6da5d7d65

View File

@ -630,7 +630,9 @@ static ssize_t uv__fs_write(uv_fs_t* req) {
*/
#if defined(__APPLE__)
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&lock);
if (pthread_mutex_lock(&lock))
abort();
#endif
if (req->off < 0) {
@ -687,7 +689,8 @@ static ssize_t uv__fs_write(uv_fs_t* req) {
done:
#if defined(__APPLE__)
pthread_mutex_unlock(&lock);
if (pthread_mutex_unlock(&lock))
abort();
#endif
return r;