In looking at changing how vdeldomain functions, I have found the function remove_line() which does the actual work of removing an entry from various qmail control files. A simple outline of how this function works:

lock the file

rename the file to the backup file name

copy entries from the backup file to a new file

delete the backup

unlock the file

On the other hand, its opposite function, update_file() works like this:

lock the file

copy the old file to a new file, adding the new entry in the process

rename the new file over the top of the original file

unlock the file


It seems to me the logic used by update_file() has a much smaller window of opportunity for a system failure to leave the mail system in an inconsistent state, and would be a better model for my new function that will delete one _or more_ lines from a qmail control file in one pass. This new function will replace remove_line() and be the foundation for changes to vdeldomain() which removes all alias domains when a primary domain is deleted.


So, is there a reason for keeping the logic in delete_line(), or should I re-write it from scratch based on update_file()?

I could reduce the failure window even more by moving all the rename operations from delete_line and update_file into the functions that call them. That way all the renames would be done at nearly the same time, after all the files have been created. Is this worth doing?


Thanks, Rick



Reply via email to