Date: Sat, 14 Jul 2018 13:39:22 +0000 (UTC) From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336276 - projects/pnfs-planb-server/sys/rpc Message-ID: <201807141339.w6EDdMD0034720@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rmacklem Date: Sat Jul 14 13:39:21 2018 New Revision: 336276 URL: https://svnweb.freebsd.org/changeset/base/336276 Log: Add a timeout to the msleep() waiting for a socket connection for the pNFS client. Without this patch, the client TCP connection code can wait a long time for a connection attempt to fail when a DS is not operational. This patch adds a timeout for this msleep() if the CLSET_TIMEOUT has been set for the connection. This is only set for TCP connections to DSs. Modified: projects/pnfs-planb-server/sys/rpc/clnt_rc.c projects/pnfs-planb-server/sys/rpc/clnt_vc.c Modified: projects/pnfs-planb-server/sys/rpc/clnt_rc.c ============================================================================== --- projects/pnfs-planb-server/sys/rpc/clnt_rc.c Sat Jul 14 10:14:59 2018 (r336275) +++ projects/pnfs-planb-server/sys/rpc/clnt_rc.c Sat Jul 14 13:39:21 2018 (r336276) @@ -175,7 +175,7 @@ clnt_reconnect_connect(CLIENT *cl) (struct sockaddr *) &rc->rc_addr, rc->rc_prog, rc->rc_vers, rc->rc_sendsz, rc->rc_recvsz); else { - if (rc->rc_timeout.tv_sec > 0 && rc->rc_timeout.tv_usec != -1) { + 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) { Modified: projects/pnfs-planb-server/sys/rpc/clnt_vc.c ============================================================================== --- projects/pnfs-planb-server/sys/rpc/clnt_vc.c Sat Jul 14 10:14:59 2018 (r336275) +++ projects/pnfs-planb-server/sys/rpc/clnt_vc.c Sat Jul 14 13:39:21 2018 (r336276) @@ -142,6 +142,8 @@ clnt_vc_create( XDR xdrs; int error, interrupted, one = 1, sleep_flag; struct sockopt sopt; + struct timeval tv; + int timo; if (disrupt == 0) disrupt = (uint32_t)(long)raddr; @@ -156,6 +158,18 @@ clnt_vc_create( ct->ct_upcallrefs = 0; if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) { + /* Check for a timeout on the soconnect(). */ + bzero(&sopt, sizeof(sopt)); + sopt.sopt_dir = SOPT_GET; + sopt.sopt_level = SOL_SOCKET; + sopt.sopt_name = SO_SNDTIMEO; + sopt.sopt_val = &tv; + sopt.sopt_valsize = sizeof(tv); + error = sogetopt(so, &sopt); + timo = 0; + if (error == 0 && tv.tv_sec > 0 && tv.tv_sec <= 600 && + tv.tv_usec >= 0) + timo = hz * tv.tv_sec; error = soconnect(so, raddr, curthread); SOCK_LOCK(so); interrupted = 0; @@ -165,9 +179,10 @@ clnt_vc_create( while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) { error = msleep(&so->so_timeo, SOCK_MTX(so), - sleep_flag, "connec", 0); + sleep_flag, "connec", timo); if (error) { - if (error == EINTR || error == ERESTART) + if (error == EINTR || error == ERESTART || + error == EAGAIN) interrupted = 1; break; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807141339.w6EDdMD0034720>