- signal (SIGALRM, closedown);
- alarm (_RPCSVC_CLOSEDOWN);
- }
-}
-
-static void closedown(sig)
-int sig;
-{
- (void) signal(sig, closedown);
- if (_rpcsvcdirty == 0) {
- static int size;
- int i, openfd;
-
- if (_rpcfdtype == SOCK_DGRAM)
- exit(0);
- if (size == 0) {
- size = getdtablesize();
- }
- for (i = 0, openfd = 0; i < size && openfd < 2; i++)
- if (FD_ISSET(i, &svc_fdset))
- openfd++;
- if (openfd <= 1)
- exit(0);
- }
- (void) alarm(_RPCSVC_CLOSEDOWN);
-}
-
-int makesock(int port, int proto)
-{
- struct sockaddr_in sin;
- int s;
- int sock_type;
- int val;
-
- sock_type = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
- s = socket(AF_INET, sock_type, proto);
- if (s < 0) {
- xlog(L_FATAL, "Could not make a socket: %s\n",
- strerror(errno));
- return (-1);
- }
- memset((char *) &sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = INADDR_ANY;
- sin.sin_port = htons(port);
-
- val = 1;
- if (proto == IPPROTO_TCP)
- if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
- &val, sizeof(val)) < 0)
- xlog(L_ERROR, "setsockopt failed: %s\n",
- strerror(errno));
-
-#if 0
- /* I was told it didn't work with gigabit ethernet.
- Don't bothet with it. H.J. */
-#ifdef SO_SNDBUF
- {
- int sblen, rblen;
-
- /* 1024 for rpc & transport overheads */
- sblen = rblen = socksz + 1024;
- if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &sblen, sizeof sblen) < 0 ||
- setsockopt(s, SOL_SOCKET, SO_RCVBUF, &rblen, sizeof rblen) < 0)
- xlog(L_ERROR, "setsockopt failed: %s\n", strerror(errno));
- }
-#endif /* SO_SNDBUF */
-#endif
-
- if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) == -1) {
- xlog(L_FATAL, "Could not bind name to socket: %s\n",
- strerror(errno));
- return (-1);