Cover V05, I05
Article
Listing 1
Listing 2
Listing 3
Sidebar 1
Sidebar 2

may96.tar


Sidebar: Off to the Races

As is often the case with queue files, you must be careful to avoid a race condition between the process reading the files and the one that is writing them. My ASAP server neatly sidesteps this problem because it is a UUCP-fed host. As such, all it has to do to rule out a race condition is run the UUCP transfer software, flush the sendmail queue, and take care of all of the ASAP spool files before performing the whole process again. Because this machine performs these operations sequentially and with only one modem, the Perl script (called by sendmail) will never write to queue files while the Kermit script is connected to a carrier and reading these files.

In a more complex environment, ASAP could be modified to use lock files. Although I have not done this, the Kermit lock file mechanism provides an apparently straightforward way to codify spool file access exclusion. That is, the process that writes the queue files, the Perl script, should ensure that Kermit does not have a lock file written in /var/spool/locks before writing to a queue file. Note that there still exists a chance that the Kermit script could begin reading the files while asap.pl writes to them. A simple way to play it safe might be to have the Perl script lock out Kermit by writing its own lock file for the serial device that the Kermit script is poised to use. The documentation on your platform's version of Kermit should provide details as to the name and location of these lock files.