X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=support%2Fnfs%2Frpcmisc.c;h=832de5fe28c89e06999301da968054a656a953d8;hb=475135e4bb90212385f19c8aac8b39bd123f0a2f;hp=64bc802d96c5417945770d2d04a87942c3964aeb;hpb=0bdb8d4f216cafb4fef03c9a1fc1f87508eed2d3;p=nfs-utils.git diff --git a/support/nfs/rpcmisc.c b/support/nfs/rpcmisc.c index 64bc802..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 makesock(int port, int proto); #define _RPCSVC_CLOSEDOWN 120 int _rpcpmstart = 0; @@ -72,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)) < 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."); @@ -98,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)) < 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."); @@ -126,7 +135,6 @@ int sig; { (void) signal(sig, closedown); if (_rpcsvcdirty == 0) { - extern fd_set svc_fdset; static int size; int i, openfd; @@ -144,9 +152,7 @@ int sig; (void) alarm(_RPCSVC_CLOSEDOWN); } -static int makesock(port, proto) -int port; -int proto; +int makesock(int port, int proto) { struct sockaddr_in sin; int s;