]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
OpenBSD: Complete implementation of afs_osi_TimedSleep
authorAntoine Verheijen <antoine@ualberta.ca>
Mon, 28 Mar 2011 16:05:40 +0000 (10:05 -0600)
committerDerrick Brashear <shadow@dementia.org>
Fri, 1 Apr 2011 17:35:20 +0000 (10:35 -0700)
The OpenBSD version of afs_osi_TimedSleep() is missing the required
afs_event structure and afs_getevent routine. This update adds them
(by borrowing a copy of the code from the FreeBSD implementation).

Reviewed-on: http://gerrit.openafs.org/4373
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit a4b8823950d0d7f3806fe9e7aed22502b72a79e4)

Change-Id: I1886cbb995a6c3e6ef3d4cc73895215d6293fe15
Reviewed-on: http://gerrit.openafs.org/4388
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/afs/OBSD/osi_sleep.c

index 6f9c19514c7366d4392abd21f579c48dae8ed50d..f06f2fbc1abbcd2c1eebc3b0701e6dc9780e9940 100644 (file)
@@ -125,6 +125,59 @@ afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok)
     return code;
 }
 
+/*
+ * All this gluck should probably also be replaced with CVs.
+ */
+typedef struct afs_event {
+    struct afs_event *next;     /* next in hash chain */
+    char *event;                /* lwp event: an address */
+    int refcount;               /* Is it in use? */
+    int seq;                    /* Sequence number: this is incremented
+                                 * by wakeup calls; wait will not return until
+                                 * it changes */
+    int cond;
+} afs_event_t;
+
+#define HASHSIZE 128
+afs_event_t *afs_evhasht[HASHSIZE];     /* Hash table for events */
+#define afs_evhash(event)       (afs_uint32) ((((long)event)>>2) & (HASHSIZE-1));
+int afs_evhashcnt = 0;
+
+/* Get and initialize event structure corresponding to lwp event (i.e. address)
+ * */
+static afs_event_t *
+afs_getevent(char *event)
+{
+    afs_event_t *evp, *newp = 0;
+    int hashcode;
+
+    AFS_ASSERT_GLOCK();
+    hashcode = afs_evhash(event);
+    evp = afs_evhasht[hashcode];
+    while (evp) {
+        if (evp->event == event) {
+            evp->refcount++;
+            return evp;
+        }
+        if (evp->refcount == 0)
+            newp = evp;
+        evp = evp->next;
+    }
+    if (!newp) {
+        newp = (afs_event_t *) osi_AllocSmallSpace(sizeof(afs_event_t));
+        afs_evhashcnt++;
+        newp->next = afs_evhasht[hashcode];
+        afs_evhasht[hashcode] = newp;
+        newp->seq = 0;
+    }
+    newp->event = event;
+    newp->refcount = 1;
+    return newp;
+}
+
+/* Release the specified event */
+#define relevent(evp) ((evp)->refcount--)
+
 int
 afs_osi_TimedSleep(void *event, afs_int32 ams, int aintok)
 {