return code;
}
-
-
-
typedef struct afs_event {
struct afs_event *next; /* next in hash chain */
char *event; /* lwp event: an address */
{
struct afs_event *evp;
int seq, retval;
-#ifdef DECLARE_WAITQUEUE
- DECLARE_WAITQUEUE(wait, current);
-#else
- struct wait_queue wait = { current, NULL };
-#endif
+ int code;
evp = afs_getevent(event);
if (!evp) {
seq = evp->seq;
retval = 0;
- add_wait_queue(&evp->cond, &wait);
- while (seq == evp->seq) {
- set_current_state(TASK_INTERRUPTIBLE);
- AFS_ASSERT_GLOCK();
- AFS_GUNLOCK();
- schedule();
- afs_try_to_freeze();
+ AFS_GUNLOCK();
+ code = wait_event_freezable(evp->cond, seq != evp->seq);
+ AFS_GLOCK();
- AFS_GLOCK();
- if (signal_pending(current)) {
- retval = EINTR;
- break;
- }
- }
- remove_wait_queue(&evp->cond, &wait);
- set_current_state(TASK_RUNNING);
+ if (code == -ERESTARTSYS)
+ code = EINTR;
+ else
+ code = -code;
relevent(evp);
- return retval;
+ return code;
}
/* afs_osi_Sleep -- waits for an event to be notified, ignoring signals.
int code = 0;
long ticks = (ams * HZ / 1000) + 1;
struct afs_event *evp;
-#ifdef DECLARE_WAITQUEUE
- DECLARE_WAITQUEUE(wait, current);
-#else
- struct wait_queue wait = { current, NULL };
-#endif
+ int seq;
evp = afs_getevent(event);
if (!evp) {
evp = afs_getevent(event);
}
- add_wait_queue(&evp->cond, &wait);
- set_current_state(TASK_INTERRUPTIBLE);
- /* always sleep TASK_INTERRUPTIBLE to keep load average
- * from artifically increasing. */
- AFS_GUNLOCK();
-
- if (schedule_timeout(ticks)) {
- if (aintok)
- code = EINTR;
- }
-
- afs_try_to_freeze();
+ seq = evp->seq;
+ AFS_GUNLOCK();
+ code = wait_event_freezable_timeout(evp->cond, evp->seq != seq, ticks);
AFS_GLOCK();
- remove_wait_queue(&evp->cond, &wait);
- set_current_state(TASK_RUNNING);
+ if (code == -ERESTARTSYS)
+ code = EINTR;
+ else
+ code = -code;
relevent(evp);