Use the correct API for msleep() in FBSD's afs_osi_TimedSleep()
authorBen Kaduk <kaduk@mit.edu>
Sat, 6 Mar 2010 20:20:18 +0000 (15:20 -0500)
committerDerrick Brashear <shadow@dementia.org>
Tue, 9 Mar 2010 05:10:39 +0000 (21:10 -0800)
msleep() does not take a struct timespec*, it takes its timeout
value as a multiple of the kernel's HZ parameter (tuneable at
startup).  Since the afs_osi_TimedSleep interface is documented
to take a timeout in milliseconds, we must correct for the (sometimes)
different units (currently HZ defaults to 1000).  We prefer
to multiply the timeout by HZ before dividing by 1000 so as to
not lose precision; overflow is assumed to be unlikely.

Change-Id: Ic101f3bf54213eebe249cb6c40a6d8cbd3d722f0
Reviewed-on: http://gerrit.openafs.org/1539
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/afs/FBSD/osi_sleep.c

index ebf22ed..116a1bc 100644 (file)
@@ -264,7 +264,6 @@ afs_osi_TimedSleep(void *event, afs_int32 ams, int aintok)
     int code = 0;
     struct afs_event *evp;
     int seq, prio;
-    struct timespec ts;
 
     evp = afs_getevent(event);
     seq = evp->seq;
@@ -273,10 +272,8 @@ afs_osi_TimedSleep(void *event, afs_int32 ams, int aintok)
        prio = PCATCH | PPAUSE;
     else
        prio = PVFS;
-    ts.tv_sec = ams / 1000;
-    ts.tv_nsec = (ams % 1000) * 1000000;
     evp->owner = 0;
-    code = msleep(event, evp->lck, prio, "afsslp", &ts);
+    code = msleep(event, evp->lck, prio, "afsslp", (ams * hz) / 1000);
     evp->owner = curthread;
     if (seq == evp->seq)
        code = EINTR;