Bug 1285074 - Fix pthreads error reporting for posix js::Mutex; r=terrence

The old code assumed that various pthreads calls would set errno, and therefore
we could use perror() to print information about them. That assumption was
incorrect: pthreads calls return the error number directly and do not set errno
at all. The solution: asign the return value to errno and then call perror();
This commit is contained in:
Nick Fitzgerald 2016-08-08 10:37:54 -07:00
Родитель c10280ebcf
Коммит 4edf614ff4
1 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <errno.h>
#include <pthread.h> #include <pthread.h>
#include <stdio.h> #include <stdio.h>
@ -13,10 +14,15 @@
#include "threading/posix/MutexPlatformData.h" #include "threading/posix/MutexPlatformData.h"
#define TRY_CALL_PTHREADS(call, msg) \ #define TRY_CALL_PTHREADS(call, msg) \
if ((call) != 0) { \ { \
perror(msg); \ int result = (call); \
MOZ_CRASH(msg); \ if (result != 0) { \
} MOZ_ASSERT(!errno); \
errno = result; \
perror(msg); \
MOZ_CRASH(msg); \
} \
}
js::Mutex::Mutex() js::Mutex::Mutex()
{ {