From owner-svn-src-projects@freebsd.org Sat Jul 14 13:39:23 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1AB7102B5A3 for ; Sat, 14 Jul 2018 13:39:22 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A11E07A1C3; Sat, 14 Jul 2018 13:39:22 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 82B8E1FAE1; Sat, 14 Jul 2018 13:39:22 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6EDdMq8034722; Sat, 14 Jul 2018 13:39:22 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6EDdMD0034720; Sat, 14 Jul 2018 13:39:22 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807141339.w6EDdMD0034720@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Sat, 14 Jul 2018 13:39:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336276 - projects/pnfs-planb-server/sys/rpc X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/pnfs-planb-server/sys/rpc X-SVN-Commit-Revision: 336276 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jul 2018 13:39:23 -0000 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; }