/* select.c - select() abstractions */
static char *rcsid
= "$Header: /f/osi/compat/RCS/select.c,v 7.6 91/02/22 09:15:45 mrose Interim $";
* $Header: /f/osi/compat/RCS/select.c,v 7.6 91/02/22 09:15:45 mrose Interim $
* Revision 7.6 91/02/22 09:15:45 mrose
* Revision 7.5 91/01/07 12:39:56 mrose
* Revision 7.4 90/11/21 11:35:31 mrose
* Revision 7.3 90/05/22 19:33:29 mrose
* Revision 7.2 89/12/05 22:04:41 mrose
* Revision 7.1 89/11/30 23:53:31 mrose
* Revision 7.0 89/11/23 21:23:24 mrose
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
int xselect_blocking_on_intr
= 0;
/* Synchronous multiplexing:
int selsocket (nfds
, rfds
, wfds
, efds
, secs
)
register struct timeval
*tv
= &tvs
;
tv
-> tv_sec
= secs
, tv
-> tv_usec
= 0;
switch (n
= select (nfds
, rfds
, wfds
, efds
, tv
)) {
if (xselect_blocking_on_intr
/* There seems to be a bug in the SYS5 EXOS select() routine when a socket can
be read immediately (don't know about write). The bug is that select()
returns ZERO, and the mask is zero'd as well. The code below explicitly
int selsocket (nfds
, rfds
, wfds
, efds
, secs
)
usecs
= 0xffff; /* used to be ~(1L << (8 * sizeof usecs - 1)) */
switch (n
= select (nfds
+ 1, rfds
, wfds
, usecs
)) { /* +1 for UNISYS */
for (fd
= 0; fd
< nfds
; fd
++)
&& ioctl (fd
, FIONREAD
, (char *) &nbytes
)
if (n
== 0 && secs
== NOTOK
)
/* This routine used to be used for devices that didn't support real select.
Those devices are no longer supported.
Instead the routine is used to check if an I/O abstraction has some data
buffered in user-space for reading...
static IFP sfnx
[FD_SETSIZE
] = { NULL
};
static caddr_t sdata
[FD_SETSIZE
] = { NULL
};
IFP
set_check_fd (fd
, fnx
, data
)
if (fd
< 0 || fd
>= FD_SETSIZE
)
sfnx
[fd
] = fnx
, sdata
[fd
] = data
;
int xselect (nfds
, rfds
, wfds
, efds
, secs
)
static int nsysfds
= NOTOK
;
nsysfds
= getdtablesize ();
for (fd
= 0; fd
< nfds
; fd
++)
&& (*sfnx
[fd
]) (fd
, sdata
[fd
]) == DONE
) {
*rfds
= ifds
; /* struct copy */
ifds
= *rfds
; /* struct copy */
ofds
= *wfds
; /* struct copy */
xfds
= *efds
; /* struct copy */
if ((n
= selsocket (nfds
, rfds
, wfds
, efds
, secs
)) != NOTOK
)
for (fd
= 0; fd
< nfds
; fd
++)
if (((rfds
&& FD_ISSET (fd
, &ifds
))
|| (wfds
&& FD_ISSET (fd
, &ofds
))
|| (efds
&& FD_ISSET (fd
, &xfds
)))
&& fstat (fd
, &st
) == NOTOK
) {
if (rfds
&& FD_ISSET (fd
, &ifds
))
if (wfds
&& FD_ISSET (fd
, &ofds
))
if (efds
&& FD_ISSET (fd
, &xfds
))
SLOG (compat_log
, LLOG_EXCEPTIONS
, "",
("fd %d has gone bad", fd
));