Tuesday, 21 August 2007

Installation: File copy race condition for executable Perl programs

Modified the {\tt publish} and {\tt production} targets in the {\tt Makefile} to install the executable Perl components ({\tt HackDiet}, {\tt HackDietBadge}, and {\tt ClusterSync}) by copying them to the destination directories with an extension of {\tt .NEW} and then renaming them to the destination name. This avoids the possible race condition when a request arrives while the file is being copied to the server and the CGI process attempts to read the Perl program before it has been entirely copied. Note that we still have a potential race condition for the modules in {\tt HDiet}, but as these files are much smaller, the odds of encountering it are much less than with the large main program. I will eventually change these to install with a copy and move strategy as well, but that will require more work since they are installed with a recursive copy rather than a simple file copy.

No comments: