By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

using flock for concurrency control

P: n/a
I have an application that maintains its configuration file. This file
is read frequently but written to very rarely. There may be several
processes attempting to read and write to the config file.
The application reads the configuration file into a buffer, inflicts
changes on the buffer and writes the buffer to the file.
The intended logic for writing the buffer into the config file is as

# create a copy of config.txt say as config.txt.bak
open CONFIG_FILE, "config.txt";
eval {
print CONFIG_FILE "blah blah blah";
if ($@)
#move config.txt.bak to config.txt

An issue arises when the writer process is at "CRITICAL POINT" and
another reader process attempts to read the config. File. Since the
write operation has failed, the current config. File is corrupt and the
original config. File has not been restored yet. So the reader process
gets into trouble.

Any idea on how to tackle this?


Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.