Author: rmacklem Date: Fri Jul 20 12:03:16 2018 New Revision: 336542 URL: https://svnweb.freebsd.org/changeset/base/336542
Log: Set SO_SNDTIMEO in the client side krpc when CLSET_TIMEOUT is done. During testing of the pNFS client, it was observed that an RPC could get stuck in sosend() for a very long time if the network connection to a DS had failed. This is fixed by setting SO_SNDTIMEO on the TCP socket. This is only done when CLSET_TIMEOUT is done and this is not done by any use of the krpc currently in the source tree, so there should be no effect on extant uses. A future patch will use CLSET_TIMEOUT for TCP connections to DSs. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D16293 Modified: head/sys/rpc/clnt_rc.c Modified: head/sys/rpc/clnt_rc.c ============================================================================== --- head/sys/rpc/clnt_rc.c Fri Jul 20 07:16:28 2018 (r336541) +++ head/sys/rpc/clnt_rc.c Fri Jul 20 12:03:16 2018 (r336542) @@ -174,10 +174,26 @@ clnt_reconnect_connect(CLIENT *cl) newclient = clnt_dg_create(so, (struct sockaddr *) &rc->rc_addr, rc->rc_prog, rc->rc_vers, rc->rc_sendsz, rc->rc_recvsz); - else + else { + /* + * I do not believe a timeout of less than 1sec would make + * sense here since short delays can occur when a server is + * temporarily overloaded. + */ + if (rc->rc_timeout.tv_sec > 0 && rc->rc_timeout.tv_usec >= 0) { + error = so_setsockopt(so, SOL_SOCKET, SO_SNDTIMEO, + &rc->rc_timeout, sizeof(struct timeval)); + if (error != 0) { + stat = rpc_createerr.cf_stat = RPC_CANTSEND; + rpc_createerr.cf_error.re_errno = error; + td->td_ucred = oldcred; + goto out; + } + } newclient = clnt_vc_create(so, (struct sockaddr *) &rc->rc_addr, rc->rc_prog, rc->rc_vers, rc->rc_sendsz, rc->rc_recvsz, rc->rc_intr); + } td->td_ucred = oldcred; if (!newclient) { _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"