X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fnfs%2Frpcmisc.c;h=832de5fe28c89e06999301da968054a656a953d8;hp=4bb4ec8ce2963b12f4d1e1d6f62cf87fd7539b49;hb=87fe487c6f5abe9f40f2f036c3cf6c7f02fa0385;hpb=df07daea1421c80ecf308a6daf3ab3fa7d4cfd65 diff --git a/support/nfs/rpcmisc.c b/support/nfs/rpcmisc.c index 4bb4ec8..832de5f 100644 --- a/support/nfs/rpcmisc.c +++ b/support/nfs/rpcmisc.c @@ -29,10 +29,11 @@ #include #include #include +#include #include "nfslib.h" static void closedown(int sig); -static int makesock(int port, int proto, int socksz); +int makesock(int port, int proto); #define _RPCSVC_CLOSEDOWN 120 int _rpcpmstart = 0; @@ -40,8 +41,7 @@ int _rpcfdtype = 0; int _rpcsvcdirty = 0; void -rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport, - int bufsiz) +rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport) { struct sockaddr_in saddr; SVCXPRT *transp; @@ -73,11 +73,15 @@ rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport, transp = last_transp; goto udp_transport; } - if ((sock = makesock(defport, IPPROTO_UDP, bufsiz)) < 0) { + if (defport == 0) + sock = RPC_ANYSOCK; + else if ((sock = makesock(defport, IPPROTO_UDP)) < 0) { xlog(L_FATAL, "%s: cannot make a UDP socket\n", name); } } + if (sock == RPC_ANYSOCK) + sock = svcudp_socket (prog, 1); transp = svcudp_create(sock); if (transp == NULL) { xlog(L_FATAL, "cannot create udp service."); @@ -99,11 +103,15 @@ rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport, transp = last_transp; goto tcp_transport; } - if ((sock = makesock(defport, IPPROTO_TCP, bufsiz)) < 0) { + if (defport == 0) + sock = RPC_ANYSOCK; + else if ((sock = makesock(defport, IPPROTO_TCP)) < 0) { xlog(L_FATAL, "%s: cannot make a TCP socket\n", name); } } + if (sock == RPC_ANYSOCK) + sock = svctcp_socket (prog, 1); transp = svctcp_create(sock, 0, 0); if (transp == NULL) { xlog(L_FATAL, "cannot create tcp service."); @@ -127,7 +135,6 @@ int sig; { (void) signal(sig, closedown); if (_rpcsvcdirty == 0) { - extern fd_set svc_fdset; static int size; int i, openfd; @@ -145,10 +152,7 @@ int sig; (void) alarm(_RPCSVC_CLOSEDOWN); } -static int makesock(port, proto, socksz) -int port; -int proto; -int socksz; +int makesock(int port, int proto) { struct sockaddr_in sin; int s; @@ -171,6 +175,9 @@ int socksz; 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; @@ -182,6 +189,7 @@ int socksz; 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",