看板 FB_bugs 關於我們 聯絡資訊
The following reply was made to PR bin/113239; it has been noted by GNATS. From: Guy Helmer <guy.helmer@gmail.com> 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 <sys/fcntl.h> +#include <sys/file.h> #include <sys/types.h> #include <sys/stat.h> #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; _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscribe@freebsd.org"