#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$Id: svc_tcp.c,v 1.2 1999/10/14 21:56:54 wsanchez Exp $";
+static char *rcsid = "$Id: svc_tcp.c,v 1.6 2004/06/11 16:28:07 majka Exp $";
#endif
/*
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include <rpc/rpc.h>
#include <sys/socket.h>
#include <errno.h>
-extern bool_t abort();
-extern errno;
+
+#define max(a, b) (((a) > (b)) ? (a) : (b))
+
+extern int bindresvport();
/*
* Ops vector for TCP/IP based rpc service handle
/*
* Ops vector for TCP/IP rendezvous handler
*/
+static bool_t rendezvous_abort();
static bool_t rendezvous_request();
static enum xprt_stat rendezvous_stat();
static struct xp_ops svctcp_rendezvous_op = {
rendezvous_request,
rendezvous_stat,
- abort,
- abort,
- abort,
+ rendezvous_abort,
+ rendezvous_abort,
+ rendezvous_abort,
svctcp_destroy
};
return (xprt);
}
+static bool_t
+rendezvous_abort()
+{
+ abort();
+ return (FALSE);
+}
+
static bool_t
rendezvous_request(xprt)
register SVCXPRT *xprt;
*/
static struct timeval wait_per_try = { 35, 0 };
+extern int svc_maxfd;
+
/*
* reads data from the tcp conection.
* any error is fatal and the connection is closed.
register int len;
{
register int sock = xprt->xp_sock;
- fd_set mask;
fd_set readfds;
-
- FD_ZERO(&mask);
- FD_SET(sock, &mask);
- do {
- readfds = mask;
- if (select(sock+1, &readfds, (int*)NULL, (int*)NULL,
- &wait_per_try) <= 0) {
- if (errno == EINTR) {
- continue;
- }
+ bool_t ready = FALSE;
+
+ do
+ {
+ FD_COPY(&svc_fdset, &readfds);
+ FD_SET(sock, &readfds);
+ if (select(max(svc_maxfd, sock) + 1, &readfds, NULL, NULL, &wait_per_try) <= 0)
+ {
+ if (errno == EINTR) continue;
goto fatal_err;
}
- } while (!FD_ISSET(sock, &readfds));
- if ((len = read(sock, buf, len)) > 0) {
- return (len);
- }
+ else if (FD_ISSET(sock, &readfds))
+ {
+ ready = TRUE;
+ }
+ } while (!ready);
+
+ if ((len = read(sock, buf, len)) > 0) return len;
+
fatal_err:
((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED;
- return (-1);
+ return -1;
}
/*