From owner-freebsd-bugs@FreeBSD.ORG Wed Jun 5 21:30:01 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7DEB4ACE for ; Wed, 5 Jun 2013 21:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 719941303 for ; Wed, 5 Jun 2013 21:30:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r55LU1NM050463 for ; Wed, 5 Jun 2013 21:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r55LU1L3050462; Wed, 5 Jun 2013 21:30:01 GMT (envelope-from gnats) Date: Wed, 5 Jun 2013 21:30:01 GMT Message-Id: <201306052130.r55LU1L3050462@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Guy Helmer Subject: Re: bin/113239: [patch] atrun(8) loses jobs due to race condition X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Guy Helmer List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 21:30:01 -0000 The following reply was made to PR bin/113239; it has been noted by GNATS. From: Guy Helmer To: bug-followup@FreeBSD.org, freebsd@sopwith.solgatos.com Cc: Subject: Re: bin/113239: [patch] atrun(8) loses jobs due to race condition Date: Wed, 5 Jun 2013 16:13:09 -0500 I'm not comfortable with working around the race condition by = determining whether a file seems "too old". Would serializing access to = the queue work using the following patch: Index: atrun.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- atrun.c (revision 251433) +++ atrun.c (working copy) @@ -31,6 +31,7 @@ /* System Headers */ =20 #include +#include #include #include #ifdef __FreeBSD__ @@ -521,6 +522,9 @@ if ((spool =3D opendir(".")) =3D=3D NULL) perr("cannot read %s", ATJOB_DIR); =20 + if (flock(dirfd(spool), LOCK_EX) =3D=3D -1) + perr("cannot lock %s", ATJOB_DIR); + now =3D time(NULL); run_batch =3D 0; batch_uid =3D (uid_t) -1;