Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners Cgi > file lock unnec...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 1391 of 1478
Post > Topic >>

file lock unnecessary?

by kanya@[EMAIL PROTECTED] Apr 25, 2007 at 04:14 PM

Hello everyone!

I have written a perl script which opens a file for reading and writing.
I tested what happens if the script is run in multiple instances by the
webserver.  I put a sleep command between seeking writing position in
the file and actual writing.  I filled the web form in two different
tabs of my browser and sent it. 

My impression was that the following happens:  
- first instance opens the file, 
- first instance seeks the writing position,
- first instance goes sleeping,
- second instance opens the same file,
- second instance seeks the writing position (different from the above
one),
- second instance goes sleeping,
- first instance wakes up,
- first instance writes the file,
- first instance closes the file,
- second instance wakes up,
- second instance writes the file,
- second instance closes the file.

After that procedure both changes has appeared in the file.

Does it mean, that on this system the multiple instance writing of a
file is handled well and I do not have to worry about locking the file
as long as the different instances write different positions in the
file?  Even the system administrator had the tip, that only the last
change will appear.

If I want to be sure that multiple instance writing will work, is append
a better choice?  I have read that on the archive of this list.

Thanks
 




 4 Posts in Topic:
file lock unnecessary?
kanya@[EMAIL PROTECTED]   2007-04-25 16:14:40 
Re: file lock unnecessary?
greg@[EMAIL PROTECTED] (  2007-04-25 06:31:16 
Re: file lock unnecessary?
kanya@[EMAIL PROTECTED]   2007-04-25 18:42:17 
Re: file lock unnecessary?
greg@[EMAIL PROTECTED] (  2007-04-25 09:14:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 19:06:20 CDT 2008.