X-Git-Url: https://git.openafs.org/?p=openafs.git;a=blobdiff_plain;f=src%2Fafs%2FOBSD%2Fosi_sleep.c;h=6f9c19514c7366d4392abd21f579c48dae8ed50d;hp=4e6b77edb744963e5d8c8bf18b4b244e89d201aa;hb=5ff6c88fcc0c35843e91dc45e4bd297efd0d4445;hpb=5f498279b827675a48c80b7c2f43c78d8e41d406 diff --git a/src/afs/OBSD/osi_sleep.c b/src/afs/OBSD/osi_sleep.c index 4e6b77e..6f9c195 100644 --- a/src/afs/OBSD/osi_sleep.c +++ b/src/afs/OBSD/osi_sleep.c @@ -44,8 +44,6 @@ such damages. #include #include "afs/param.h" -RCSID - ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afs/afsincludes.h" /* Afs-based standard headers */ @@ -54,6 +52,21 @@ RCSID static char waitV; +time_t +osi_Time() +{ + struct timeval now; + + getmicrotime(&now); + return now.tv_sec; +} + +void +afs_osi_SetTime(osi_timeval_t * atv) +{ + printf("afs attempted to set clock; use \"afsd -nosettime\"\n"); +} + /* cancel osi_Wait */ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) @@ -76,13 +89,14 @@ int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { int timo, code = 0; - struct timeval atv, endTime; + struct timeval atv, now, endTime; AFS_STATCNT(osi_Wait); atv.tv_sec = ams / 1000; atv.tv_usec = (ams % 1000) * 1000; - timeradd(&atv, &time, &endTime); + getmicrotime(&now); + timeradd(&atv, &now, &endTime); if (ahandle) ahandle->proc = (caddr_t) curproc; @@ -90,7 +104,7 @@ afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) AFS_GUNLOCK(); do { - timersub(&endTime, &time, &atv); + timersub(&endTime, &now, &atv); timo = atv.tv_sec * hz + atv.tv_usec * hz / 1000000 + 1; if (aintok) { code = tsleep(&waitV, PCATCH | PVFS, "afs_W1", timo); @@ -104,28 +118,50 @@ afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) /* we've been signalled */ break; } - } while (timercmp(&time, &endTime, <)); + getmicrotime(&now); + } while (timercmp(&now, &endTime, <)); AFS_GLOCK(); return code; } +int +afs_osi_TimedSleep(void *event, afs_int32 ams, int aintok) +{ + int code = 0; + struct afs_event *evp; + int seq, prio; + int ticks; + + evp = afs_getevent(event); + seq = evp->seq; + AFS_GUNLOCK(); + if (aintok) + prio = PCATCH | PPAUSE; + else + prio = PVFS; + ticks = (ams * afs_hz) / 1000; + code = tsleep(event, prio, "afs_osi_TimedSleep", ticks); + if (seq == evp->seq) + code = EINTR; + relevent(evp); + AFS_GLOCK(); + return code; +} + void afs_osi_Sleep(void *event) { AFS_ASSERT_GLOCK(); AFS_GUNLOCK(); - tsleep(event, PVFS, "afs", 0); + tsleep(event, PVFS, "afsslp", 0); AFS_GLOCK(); } int afs_osi_SleepSig(void *event) { - AFS_ASSERT_GLOCK(); - AFS_GUNLOCK(); - tsleep(event, PVFS, "afs", 0); - AFS_GLOCK(); + afs_osi_Sleep(event); return 0; }