"Sebastian Bazley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> When VMS Perl (5.5-3A3) opens files, it uses the C RTL open(), which
> defaults to exclusive mode, even for read.
>
> This means that Perl cannot read files that are open for write, even if
the
> writer specified that sharing was allowed. For example, it cannot read
batch
> log files (it reports %RMS-E-FLK), though the VMS utilities TYPE and
> EDIT/TPU etc can read the file.
>
> One way round this is to use vmsopen("file","shr=put"), but this is
awkward
> to implement if the script is to be used on other systems. And it makes
> one-liners quite tricky...
>
> I've just discovered that recent versions of the DECC RTL allow one to
> over-ride the default file open mode: (from
> http://h71000.www7.hp.com/doc/731FINAL/5763/5763pro_005.html)
>
> "DECC$FILE_SHARING
> With DECC$FILE_SHARING enabled, all files are opened with full sharing
> enabled (FAB$M_DEL | FAB$M_GET | FAB$M_PUT | FAB$M_UPD). This is set as a
> logical OR with any sharing mode specified by the caller."
>
> Unfortunately, there does not appear to be a logical which only applies to
> files opened for read, so this also affects output files.
>
> My view is that Perl should open _input_ files using non-exclusive mode,
as
> it should be up to the writer of the file to use exlusive access if
readers
> are not allowed.
>
> [Perhaps this is the case with more recent versions of VMS Perl - I've not
> checked.]
>
> With the DECC$FILE_SHARING logical it is possible to get behaviour which
is
> closer to the way that Perl behaves on other OSes.
>
> -- 
I believe you will take a decent performance hit if you default all files to
open in shared access.  Also all shared access should be done using Record
Oriented File I/O instead of Stream Oriented File I/O as described by the C
RTL documentation for VMS.  Also you need to flush your output to have the
data to be seen by any reader.  From my testing I can build a 10000 line
text file in about 1 second if I only flush once for the whole file, but it
takes over 2 minutes if I flush each line.  In some cases you may really
need the shared access but in a lot of cases you won't.  So it does mean you
have to have specific code for those cases, but I believe in the long run
it's better not to default to shared access.  That is why I believe they set
up the DECC$FILE_SHARING logical so it is easy for someone to switch to
shared access, but you need to be aware of the performance hit you will
take.

Hope that makes sense.

Michael


Reply via email to