[Info-vax] Multiple File Readers/Writers
chrisj.doran%proemail.co.uk at gtempaccount.com
chrisj.doran%proemail.co.uk at gtempaccount.com
Fri Nov 25 02:43:57 EST 2011
On Nov 25, 1:48 am, chrisj.doran%proemail.co... at gtempaccount.com
wrote:
> On Nov 25, 1:29 am, Matt <matt-nos... at 9track.net> wrote:
>
>
>
>
>
> > I'm trying to port SQLite to OpenVMS/Integrity. It's mostly working so
> > far with only a few minor changes required thanks to the 'unix
> > compatibility' layer in the C runtime library. However what doesn't work
> > is the ability for multiple processes to access the same database file
> > at the same time.
>
> > I've written two small test programs using the same functions as the
> > SQLite module to demonstrate the problem. One is called 'writer' which
> > opens a file test.dat and writes a counter every second into the first
> > few bytes. The second program 'reader' opens the same file and displays
> > the counter once per second. I've tried them on Windows and Linux and
> > they work as expected, however on VMS the counter never updates and the
> > reader seems to be dealing with a cached version of the file on disk.
> > The only way to get the counter to update is to close and open the file
> > on every read operation.
>
> > I've read the relevant sections of 'Guide to OpenVMS File Applications',
> > 'OpenVMS Record Management Services Reference Manual' and the 'C
> > Run-Time Library Reference Manual' and tried many combinations of
> > options but always get the same result.
>
> > What combination of parameters do I need to pass to the 'open' call to
> > get the file sharing to work properly so that the reader does not get
> > stale data?
>
> > The test programs are located here:
>
> >http://www.9track.net/vms/reader.chttp://www.9track.net/vms/writer.c
>
> > Thanks,
>
> > Matt
>
> It's been a while, but I have a vague recollection of having the same
> problem and needing to replace fsync with fflush, or use both, despite
> the docs implying they do the same thing. Sorry, don't have time to
> investigate at this precise moment.
>
> Chris- Hide quoted text -
>
> - Show quoted text -
Sorry, forget what I said; I must have been thinking of some other
problem/system. As you say, the problem is in the reader, as DUMP
shows the file changing.
I note that my (rather old) manual says that "file sharing is not
supported for stream files" but setting ctx=rec doesn't help. Nor does
turning off buffering with setvbuf. I've tried various other things,
but still can't get it to work. I'll keep thinking.
Maybe there's a better way to sync. ISTR that when I needed to do
something similar, I checked the last update time of the file.
I found a couple of buglets, though: You've omitted the mode argument
to open which results in funny file protection, and tested fd instead
of rc after lseek() and read(). But these don't affect the problem.
Chris
More information about the Info-vax
mailing list