From owner-svn-src-all@FreeBSD.ORG Tue Aug 13 19:20:51 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 9EF7335D; Tue, 13 Aug 2013 19:20:51 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8C2BD2E82; Tue, 13 Aug 2013 19:20:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7DJKpsT054757; Tue, 13 Aug 2013 19:20:51 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7DJKpA7054755; Tue, 13 Aug 2013 19:20:51 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201308131920.r7DJKpA7054755@svn.freebsd.org> From: Jilles Tjoelker Date: Tue, 13 Aug 2013 19:20:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254289 - in head/lib/libc/db: btree hash X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Aug 2013 19:20:51 -0000 Author: jilles Date: Tue Aug 13 19:20:50 2013 New Revision: 254289 URL: http://svnweb.freebsd.org/changeset/base/254289 Log: db: Use O_CLOEXEC instead of separate fcntl() call. Modified: head/lib/libc/db/btree/bt_open.c head/lib/libc/db/hash/hash_page.c Modified: head/lib/libc/db/btree/bt_open.c ============================================================================== --- head/lib/libc/db/btree/bt_open.c Tue Aug 13 18:51:26 2013 (r254288) +++ head/lib/libc/db/btree/bt_open.c Tue Aug 13 19:20:50 2013 (r254289) @@ -196,7 +196,7 @@ __bt_open(const char *fname, int flags, goto einval; } - if ((t->bt_fd = _open(fname, flags, mode)) < 0) + if ((t->bt_fd = _open(fname, flags | O_CLOEXEC, mode)) < 0) goto err; } else { @@ -207,9 +207,6 @@ __bt_open(const char *fname, int flags, F_SET(t, B_INMEM); } - if (_fcntl(t->bt_fd, F_SETFD, 1) == -1) - goto err; - if (_fstat(t->bt_fd, &sb)) goto err; if (sb.st_size) { @@ -405,7 +402,7 @@ tmp(void) (void)sigfillset(&set); (void)_sigprocmask(SIG_BLOCK, &set, &oset); - if ((fd = mkstemp(path)) != -1) + if ((fd = mkostemp(path, O_CLOEXEC)) != -1) (void)unlink(path); (void)_sigprocmask(SIG_SETMASK, &oset, NULL); return(fd); Modified: head/lib/libc/db/hash/hash_page.c ============================================================================== --- head/lib/libc/db/hash/hash_page.c Tue Aug 13 18:51:26 2013 (r254288) +++ head/lib/libc/db/hash/hash_page.c Tue Aug 13 19:20:50 2013 (r254289) @@ -862,10 +862,8 @@ open_temp(HTAB *hashp) /* Block signals; make sure file goes away at process exit. */ (void)sigfillset(&set); (void)_sigprocmask(SIG_BLOCK, &set, &oset); - if ((hashp->fp = mkstemp(path)) != -1) { + if ((hashp->fp = mkostemp(path, O_CLOEXEC)) != -1) (void)unlink(path); - (void)_fcntl(hashp->fp, F_SETFD, 1); - } (void)_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); return (hashp->fp != -1 ? 0 : -1); }