From 7cbd4b199f783e1ae9aaa1d3904e2700dbfcf48d Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 7 Aug 2006 16:37:13 +1000 Subject: "rpc.nfsd XX" should not fail if ports are already open. support/nfs/nfssvc.c: if any ports are already open, don't try to open any more. This means that once nfsd is running rpc.nfsd X will just change the number of threads, not the ports in use. --- support/nfs/nfssvc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'support') diff --git a/support/nfs/nfssvc.c b/support/nfs/nfssvc.c index 1feffdd..ef7d8e1 100644 --- a/support/nfs/nfssvc.c +++ b/support/nfs/nfssvc.c @@ -28,11 +28,25 @@ static void nfssvc_setfds(int port, unsigned int ctlbits, char *haddr) { - int fd, on=1; + int fd, n, on=1; char buf[BUFSIZ]; int udpfd = -1, tcpfd = -1; struct sockaddr_in sin; + fd = open(NFSD_PORTS_FILE, O_RDONLY); + if (fd < 0) + return; + n = read(fd, buf, BUFSIZ); + close(fd); + if (n != 0) + return; + /* there are no ports currently open, so it is safe to + * try to open some and pass them through. + * Note: If the user explicitly asked for 'udp', then + * we should probably check if that is open, and should + * open it if not. However we don't yet. All sockets + * have to be opened when the first daemon is started. + */ fd = open(NFSD_PORTS_FILE, O_WRONLY); if (fd < 0) return; -- cgit