]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-darwin-lost-wakeups-20051223
authorChaskiel M Grundman <cg2v@andrew.cmu.edu>
Sat, 24 Dec 2005 00:10:02 +0000 (00:10 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sat, 24 Dec 2005 00:10:02 +0000 (00:10 +0000)
FIXES 24492

rewrite for tiger to avoid losing wakeups

(cherry picked from commit 856f5288e761e9dfaf720eb38a9bd4e7a053cb0d)

src/rx/DARWIN/rx_kmutex.h

index 07fb0246f69ffb86cb6f20f8588fa34c248f0572..cf3f9aae9a4b2b8558f73ebec33713adb0d817da 100644 (file)
 #define CV_DESTROY(cv)
 #ifdef AFS_DARWIN14_ENV
 #ifdef AFS_DARWIN80_ENV
-#define VFSSLEEP(cv) msleep(cv, NULL, PVFS, "afs_CV_WAIT", NULL)
-#define VFSTSLEEP(cv,t) do { \
-   struct timespec ts; \
-   ts.ts_sec = t; \
-   ts.ts_nsec = 0; \
-   msleep(cv, NULL, PVFS, "afs_CV_TIMEDWAIT", &ts); \
-} while(0)
+#define CV_WAIT(cv, lck)    do { \
+                               int isGlockOwner = ISAFS_GLOCK(); \
+                               if (isGlockOwner) AFS_GUNLOCK();  \
+                               osi_Assert((lck)->owner == current_thread()); \
+                               (lck)->owner = (thread_t)0; \
+                               lck_mtx_lock((lck)->meta); \
+                               (lck)->waiters--; \
+                               lck_mtx_unlock((lck)->meta); \
+                                msleep(cv, (lck)->lock, PDROP|PVFS, "afs_CV_WAIT", NULL); \
+                               if (isGlockOwner) AFS_GLOCK();  \
+                               MUTEX_ENTER(lck); \
+                           } while(0)
+
+#define CV_TIMEDWAIT(cv,lck,t)  do { \
+                               struct timespec ts; \
+                               int isGlockOwner = ISAFS_GLOCK(); \
+                               ts.ts_sec = t; \
+                               ts.ts_nsec = 0; \
+                               if (isGlockOwner) AFS_GUNLOCK();  \
+                               osi_Assert((lck)->owner == current_thread()); \
+                               (lck)->owner = (thread_t)0; \
+                               lck_mtx_lock((lck)->meta); \
+                               (lck)->waiters--; \
+                               lck_mtx_unlock((lck)->meta); \
+                                msleep(cv, (lck)->lock, PDROP|PVFS, "afs_CV_TIMEDWAIT", &ts); \
+                               if (isGlockOwner) AFS_GLOCK();  \
+                               MUTEX_ENTER(lck);       \
+                            } while(0)
 #else
-#define VFSSLEEP(cv) sleep(cv, PVFS)
-#define VFSTSLEEP(cv, t) tsleep(cv,PVFS, "afs_CV_TIMEDWAIT",t)
-#endif
 #define CV_WAIT(cv, lck)    do { \
                                int isGlockOwner = ISAFS_GLOCK(); \
                                if (isGlockOwner) AFS_GUNLOCK();  \
                                MUTEX_EXIT(lck);        \
-                               VFSSLEEP(cv);                \
+                               sleep(cv, PVFS);                \
                                if (isGlockOwner) AFS_GLOCK();  \
                                MUTEX_ENTER(lck); \
                            } while(0)
                                int isGlockOwner = ISAFS_GLOCK(); \
                                if (isGlockOwner) AFS_GUNLOCK();  \
                                MUTEX_EXIT(lck);        \
-                               VFSTSLEEP(cv,t);  \
+                               tsleep(cv,PVFS, "afs_CV_TIMEDWAIT",t);  \
                                if (isGlockOwner) AFS_GLOCK();  \
                                MUTEX_ENTER(lck);       \
                             } while(0)
-
+#endif
 #define CV_SIGNAL(cv)           wakeup_one((void *)(cv))
 #define CV_BROADCAST(cv)        wakeup((void *)(cv))
 #else