diff options
author | peter <peter@FreeBSD.org> | 1996-12-30 15:14:29 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1996-12-30 15:14:29 +0000 |
commit | 87bdd071c6f7b51a080ed61e97902a8e98d22897 (patch) | |
tree | 266ca56648e0124e1f830681efb11141d32f3010 /lib/libc/rpc | |
parent | 667fe607cdf7aded96545a94d377236fdf06ca22 (diff) | |
download | FreeBSD-src-87bdd071c6f7b51a080ed61e97902a8e98d22897.zip FreeBSD-src-87bdd071c6f7b51a080ed61e97902a8e98d22897.tar.gz |
- overhaul for unlimited file descriptors
- prototypes now in include files
Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
Note: potential bug here, It looks like there could be a null pointer
dereference depending on what has already been called to initialise some
shared data.
Diffstat (limited to 'lib/libc/rpc')
-rw-r--r-- | lib/libc/rpc/svc_run.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/lib/libc/rpc/svc_run.c b/lib/libc/rpc/svc_run.c index 5c84864..0010f65 100644 --- a/lib/libc/rpc/svc_run.c +++ b/lib/libc/rpc/svc_run.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc_run.c,v 1.2 1995/05/30 05:41:35 rgrimes Exp $"; +static char *rcsid = "$Id: svc_run.c,v 1.3 1996/06/10 00:49:19 jraynard Exp $"; #endif /* @@ -43,36 +43,45 @@ static char *rcsid = "$Id: svc_run.c,v 1.2 1995/05/30 05:41:35 rgrimes Exp $"; #include <sys/types.h> #include <sys/time.h> #include <unistd.h> +#include <stdlib.h> +#include <string.h> -int _rpc_dtablesize(void); +extern int __svc_fdsetsize; +extern fd_set *__svc_fdset; void svc_run() { -#ifdef FD_SETSIZE - fd_set readfds; -#else - int readfds; -#endif /* def FD_SETSIZE */ + fd_set *fds; for (;;) { -#ifdef FD_SETSIZE - readfds = svc_fdset; -#else - readfds = svc_fds; -#endif /* def FD_SETSIZE */ - switch (select(_rpc_dtablesize(), &readfds, NULL, NULL, - (struct timeval *)0)) { + if (__svc_fdset) { + int bytes = howmany(__svc_fdsetsize, NFDBITS) * + sizeof(fd_mask); + fds = (fd_set *)malloc(bytes); + memcpy(fds, __svc_fdset, bytes); + } else + fds = NULL; + switch (select(svc_maxfd, fds, NULL, NULL, + (struct timeval *)0)) { case -1: if (errno == EINTR) { + if (fds) + free(fds); continue; } perror("svc_run: - select failed"); + if (fds) + free(fds); return; case 0: + if (fds) + free(fds); continue; default: - svc_getreqset(&readfds); + /* XXX What the hell?? what if fds == NULL?? */ + svc_getreqset2(fds, svc_maxfd + 1); + free(fds); } } } |