Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

flock

Status
Not open for further replies.

ibjdt

Programmer
Joined
Nov 25, 2002
Messages
63
i find conflicting info on file locking.

is it better to use $LOCK_SH / $LOCK_EX / $LOCK_UN when reading and writing to a db or is it ok to use
flock(DB, 2); all the time and rely on close (DB); to unlock the db??

thanks.
 
You don't really need to lock a file for reading, IMO, unless there's a ridiculous amount of updates.

You mention close (DB), I assume you're using flat files as a database, why not look into some of the perl modules, DB_File for example, and let the modules look after all the locking and stuff in the background

HTH

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I don't believe one is better than the other, but I have read from others that using $LOCK_SH / $LOCK_EX / $LOCK_UN is clearer to understand than using the numeric equivalents.
 
Status
Not open for further replies.

Similar threads

Replies
4
Views
222
  • Locked
  • Question Question
Replies
2
Views
101
Replies
2
Views
145
Replies
7
Views
324

Part and Inventory Search

Sponsor

Back
Top