[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: File Locking not working!!!!!
From:       Marshall Dudley <mdudley () EXECONN ! COM>
Date:       1998-04-18 3:38:01
[Download RAW message or body]

Leslie Mikesell wrote:
>

> Not necessarily, and even if you do it will not be lost data, it will
> be interleaving in the wrong places.  Stdio just buffers up some
> stuff and calls write() when the buffer is full or you flush it
> (or you seek on the file, or close it...).  If you send a line to
> stdio and flush, the right thing will happen unless your line exceeds
> the stdio buffer size.
>
>   Les Mikesell
>    les@mcs.com

You really have to look at what the r/w process is doing.  If you are
just adding to a file, or updating a fixed size record that would be
true.  But I was losing data because the r/w process would read in the
data file, then seek to the beginning and rewrite the entire file from
the beginning (using plain old print statements), skipping the record
that was to be deleted, then truncating the file to the new file
length.  In that case if the append occured after the read, but before
the write, the new data got appended but it never got read in by the
other process and thus did not get rewritten.  Once I added the lock to
the append as well, it gets held off until the file is completely
rewritten, and the problem is solved.

Marshall

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic