summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Dainty <matt@bodgit-n-scarper.com>2016-03-17 10:38:49 +0000
committerRiccardo Magliocchetti <riccardo.magliocchetti@gmail.com>2016-03-20 12:53:40 +0100
commit67e1005c72913732ea8ab2740e93f0b09ac370c7 (patch)
tree617f799424dcab47a85c56cbeddb69eb0fc7f220
parentb7f2616df6c286aac0a370d6876e4bcaf721bf86 (diff)
downloaduwsgi-muslfixes.tar.gz
Fix running on musl libcmuslfixes
This is following on from the work in PR #522 which reached the point that uwsgi compiled on musl libc (Alpine Linux) however it doesn't run because it fails on pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT) which returns ENOTSUP and the code treated any non-zero return value as fatal. This commit handles this specific case while still considering any other non-zero return value as an error the same as before. With this change uwsgi now runs on Alpine Linux.
-rw-r--r--core/lock.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/core/lock.c b/core/lock.c
index 20935b55..efe90b7e 100644
--- a/core/lock.c
+++ b/core/lock.c
@@ -95,9 +95,19 @@ retry:
#define PTHREAD_MUTEX_ROBUST PTHREAD_MUTEX_ROBUST_NP
#endif
if (uwsgi_pthread_robust_mutexes_enabled) {
- if (pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT)) {
- uwsgi_log("unable to set PTHREAD_PRIO_INHERIT\n");
- exit(1);
+ int ret;
+ if ((ret = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT)) != 0) {
+ switch (ret) {
+ case ENOTSUP:
+ // PTHREAD_PRIO_INHERIT will only prevent
+ // priority inversion when SCHED_FIFO or
+ // SCHED_RR is used, so this is non-fatal and
+ // also currently unsupported on musl.
+ break;
+ default:
+ uwsgi_log("unable to set PTHREAD_PRIO_INHERIT\n");
+ exit(1);
+ }
}
if (pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST)) {
uwsgi_log("unable to make the mutex 'robust'\n");