Date: Wed, 5 Jun 2013 21:30:01 GMT From: Guy Helmer <guy.helmer@gmail.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/113239: [patch] atrun(8) loses jobs due to race condition Message-ID: <201306052130.r55LU1L3050462@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306052130.r55LU1L3050462>