From owner-svn-src-projects@freebsd.org Wed Jun 8 11:24:02 2016 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2766B6F7AF for ; Wed, 8 Jun 2016 11:24:02 +0000 (UTC) (envelope-from bz@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 mx1.freebsd.org (Postfix) with ESMTPS id 852351217; Wed, 8 Jun 2016 11:24:02 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u58BO13L092141; Wed, 8 Jun 2016 11:24:01 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u58BO1IH092140; Wed, 8 Jun 2016 11:24:01 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201606081124.u58BO1IH092140@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Wed, 8 Jun 2016 11:24:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r301601 - projects/vnet/sys/netinet X-SVN-Group: projects 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.22 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: Wed, 08 Jun 2016 11:24:02 -0000 Author: bz Date: Wed Jun 8 11:24:01 2016 New Revision: 301601 URL: https://svnweb.freebsd.org/changeset/base/301601 Log: Replace the DELAY with a more sophisticated check to make sure the inps are all gone before doing the cleanup. We might decide to do a partial cleanup before polling, but for now bail on the safe side. Also use pause instead of DELAY [1]. Suggested by: rwatson [1] Sponsored by: The FreeBSD Foundation Modified: projects/vnet/sys/netinet/tcp_subr.c Modified: projects/vnet/sys/netinet/tcp_subr.c ============================================================================== --- projects/vnet/sys/netinet/tcp_subr.c Wed Jun 8 11:18:49 2016 (r301600) +++ projects/vnet/sys/netinet/tcp_subr.c Wed Jun 8 11:24:01 2016 (r301601) @@ -731,18 +731,19 @@ tcp_init(void) static void tcp_destroy(void *unused __unused) { - int error; + int error, n; /* * All our processes are gone, all our sockets should be cleaned * up, which means, we should be past the tcp_discardcb() calls. - * Sleep to let all tcpcb timers really disappear and then cleanup. - * Timewait will cleanup its queue and will be ready to go. - * XXX-BZ In theory a few ticks should be good enough to make sure - * the timers are all really gone. We should see if we could use a - * better metric here and, e.g., check a tcbcb count as an optimization? + * Sleep to let all tcpcb timers really disappear and cleanup. */ - DELAY(1000000 / hz); + do { + pause("tcpdes", hz/10); + INP_LIST_RLOCK(&V_tcbinfo); + n = V_tcbinfo.ipi_count; + INP_LIST_RUNLOCK(&V_tcbinfo); + } while (n != 0); tcp_hc_destroy(); syncache_destroy(); tcp_tw_destroy();