summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroberto@centos4 <roberto@centos4>2012-04-13 14:09:03 +0200
committerroberto@centos4 <roberto@centos4>2012-04-13 14:09:03 +0200
commitc33ec8ff56c0c202450f978fdfabbaa8c54a4496 (patch)
treef46a1fba49f01db2b27adfb8aa8fb6e2921dd2c4
parente6afeec8afac6cdca8855a1172abe53a5addcdd4 (diff)
downloaduwsgi-c33ec8ff56c0c202450f978fdfabbaa8c54a4496.tar.gz
ported locking to obsolete kernels
-rw-r--r--lock.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/lock.c b/lock.c
index 3c55a68c..8c1e3f17 100644
--- a/lock.c
+++ b/lock.c
@@ -118,6 +118,27 @@ pid_t uwsgi_rwlock_fast_check(struct uwsgi_lock_item *uli) {
#endif
}
+
+void uwsgi_lock_fast(struct uwsgi_lock_item *uli) {
+
+#ifdef EOWNERDEAD
+ if (pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr) == EOWNERDEAD) {
+ uwsgi_log("[deadlock-detector] a process holding a robust mutex died. recovering...\n");
+ pthread_mutex_consistent_np((pthread_mutex_t *) uli->lock_ptr);
+ }
+#else
+ pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr);
+#endif
+ uli->pid = uwsgi.mypid;
+}
+
+void uwsgi_unlock_fast(struct uwsgi_lock_item *uli) {
+
+ pthread_mutex_unlock((pthread_mutex_t *) uli->lock_ptr);
+ uli->pid = 0;
+
+}
+
void uwsgi_rlock_fast(struct uwsgi_lock_item *uli) {
#ifdef OBSOLETE_LINUX_KERNEL
uwsgi_lock_fast(uli);
@@ -145,30 +166,10 @@ void uwsgi_rwunlock_fast(struct uwsgi_lock_item *uli) {
#endif
}
-void uwsgi_lock_fast(struct uwsgi_lock_item *uli) {
-
-#ifdef EOWNERDEAD
- if (pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr) == EOWNERDEAD) {
- uwsgi_log("[deadlock-detector] a process holding a robust mutex died. recovering...\n");
- pthread_mutex_consistent_np((pthread_mutex_t *) uli->lock_ptr);
- }
-#else
- pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr);
-#endif
- uli->pid = uwsgi.mypid;
-}
-
-void uwsgi_unlock_fast(struct uwsgi_lock_item *uli) {
-
- pthread_mutex_unlock((pthread_mutex_t *) uli->lock_ptr);
- uli->pid = 0;
-
-}
-
struct uwsgi_lock_item *uwsgi_rwlock_fast_init(char *id) {
#ifdef OBSOLETE_LINUX_KERNEL
- return uwsgi_lock_fast_init(uli);
+ return uwsgi_lock_fast_init(id);
#else
pthread_rwlockattr_t attr;