Skip to contentSkip to conversation

rpc.mountd: set nonblocking mode with libtirpc

PATCH NeilBrown 1 participant 1 message Nov 5, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

NeilBrown

author Reviewed-by
#1 lore raw
Quoted 11 lines · On 05 Nov 2014 21:23:39 +0100 [email protected] wrote:

From: Bodo Stroesser <[email protected]>
Date: Thu, 09 Oct 2014 13:07:33 +0200
Subject: [nfs-utils] [PATCH 2/3] rpc.mountd: set nonblocking mode with libtirpc

If mountd is built with libtirpc the tcp listeners and the sockets waiting for UDP messages are not in non-blocking mode. Thus if running with multiple threads (-t XX), all threads will wake up from select on a connection request or a UDP message, but only one thread will succeed. All others will wait on accept() or read() for the next event.

The two changes provide identical functionality: one in
svc_create_nconf_rand_port
the other in
svc_create_nconf_fixed_port

We really do want non-blocking sockets here!

Thanks,
NeilBrown

Quoted 25 lines

---

support/nfs/svc_create.c +7 -0
@@ -277,6 +277,12 @@
 			"(%s, %u, %s)", name, version, nconf->nc_netid);
 		return 0;
 	}
+	if (svcsock_nonblock(xprt->xp_fd) < 0) {
+		/* close() already done by svcsock_nonblock() */
+		xprt->xp_fd = RPC_ANYFD;
+		SVC_DESTROY(xprt);
+		return 0;
+	}
 
 	if (!svc_reg(xprt, program, version, dispatch, nconf)) {
 		/* svc_reg(3) destroys @xprt in this case */
@@ -332,6 +338,7 @@
 		int fd;
 
 		fd = svc_create_sock(ai->ai_addr, ai->ai_addrlen, nconf);
+		fd = svcsock_nonblock(fd);
 		if (fd == -1)
 			goto out_free;