Re: Closing TMapFiles

Valeri Fine (fine@bnl.gov)
Sun, 18 Jul 1999 20:14:43 +0200


Peter Steinberg wrote:
>
> I'm having a problem using TMapFiles to communicate between two
> processes on NT4.
>
> Since I want two-way communication, each process (let's call them
> A and B) "RECREATE"'s a mapfile for writing to the other process
> and then "READ"'s the other process's file.
>
> so we have two mapfiles showing up:
> 1. c:\AtoB.map
> 2. c:\BtoA.map
>
> Now suppose process A crashes while B is reading AtoB.map. In
> principle, B can detect this and Close() the mapfile which is
> dealing with reading AtoB.map. Then when A comes back, it can
> again perform a "RECREATE" on c:\AtoB.map and then B can reopen it.

Process B did open that file in "READ ONLY" mode and it can not close
this file properly since it was open to "write in" by another
process.
There is no such sort of protection under UNIX though.

>
> However, this does _not_ work. Even after closing the mapfile object
> which performs the read (the docs say not to delete the object!) i
> am unable to recreate it -- the error is:
> Error in <TMapFile::TMapFile>: file c:\AtoB.map already exists
>
> Is this a bug or feature?

I'll try to clarify this in a couple of days as soon as will be back
from
my trip.
But it could be a feature. UNIX system doesn't protect files (I mean
two
separate UNIX processes can open one and the same file to write in
easily.
It is not case under NT though.

With my best regards,
Valery

>
> Regards,
> Peter
>
> ---------------------------------------------------------------------------
> Peter Steinberg, Columbia University mailto:Peter.Steinberg@Cern.ch
> Nevis Laboratories + http://www.nevis.columbia.edu/~steinber
> P.O. Box 137 _ O _ Home Phone: (212) 678-5971
> (or 136 South Broadway) ( `-|-' ) Nevis: (914) 591-2817 (fax 8120)
> Irvington, NY 10533 _+|+_/ Campus: (212) 854-4653
> ----- PCS: (917) 549-3094
> BNL: (516) 344-7843
> ---------------------------------------------------------------------------