1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains the ZCheckIfNotice/select loop used for waiting for
3 * a notice, with a timeout.
5 * Created by: <Joe Random Hacker>
8 * $Author: warmenhoven $
10 * Copyright (c) 1991 by the Massachusetts Institute of Technology.
11 * For copying and distribution information, see the file
15 #include "mit-copyright.h"
18 static char rcsid_ZWaitForNotice_c
[] = "$Zephyr$";
22 #include <sys/socket.h>
24 Code_t
Z_WaitForNotice (notice
, pred
, arg
, timeout
)
26 int (*pred
) __P((ZNotice_t
*, void *));
31 struct timeval tv
, t0
;
35 retval
= ZCheckIfNotice (notice
, (struct sockaddr_in
*) 0, pred
,
37 if (retval
== ZERR_NONE
)
39 if (retval
!= ZERR_NONOTICE
)
46 gettimeofday (&t0
, (struct timezone
*) 0);
50 i
= select (fd
+ 1, &fdmask
, (fd_set
*) 0, (fd_set
*) 0, &tv
);
53 if (i
< 0 && errno
!= EINTR
)
56 retval
= ZCheckIfNotice (notice
, (struct sockaddr_in
*) 0, pred
,
58 if (retval
!= ZERR_NONOTICE
) /* includes ZERR_NONE */
61 gettimeofday (&tv
, (struct timezone
*) 0);
62 tv
.tv_usec
= t0
.tv_usec
- tv
.tv_usec
;
64 tv
.tv_usec
+= 1000000;
65 tv
.tv_sec
= t0
.tv_sec
- tv
.tv_sec
- 1;
68 tv
.tv_sec
= t0
.tv_sec
- tv
.tv_sec
;