??? Process Shared DLL and Data ??? 
Author Message
 ??? Process Shared DLL and Data ???

I'm writing a DLL to create special logfiles (in ASCII-files and/or MS Jet
database files). Everything is perfect if only one application uses this
DLL. The MFC class instances to handle the files are allocated with new()
and I increment a counter in openmyfile(...), if the file with the specified
name is still open and I decrement the counter in closemyfile(...). If the
implemented file instance counter is zero I close the file.
Now more application should use the same DLL and only one instance of this
DLL should be loaded on the NT/2000 system. Each application using this DLL
should be able to write inte the same (!!) file or database at the same
time. To serialize the calls I could use critical sections.

But:
* What I have to do to make sure that each application (process) uses the
same DLL instancen and instance data?
* What I have to do that each application (process) is able to write to or
to read from the same file?

Regards,
Roland

--
SPLINES-Software, Technical Software Development
Phone: +43-6246-75385,  Fax: +43-6246-79241

PGP Fingerprints:
Roland J. Graf = 0592 DA69 440A E137 4ED5  22AA 3D05 CF60 FABD E14E



Fri, 09 May 2003 03:00:00 GMT  
 ??? Process Shared DLL and Data ???
Hi,

Have a look at KB article Q109619.

Regards,

--
Adrian O' Neill
Remove * in email address to reply



Quote:
> I'm writing a DLL to create special logfiles (in ASCII-files and/or MS Jet
> database files). Everything is perfect if only one application uses this
> DLL. The MFC class instances to handle the files are allocated with new()
> and I increment a counter in openmyfile(...), if the file with the
specified
> name is still open and I decrement the counter in closemyfile(...). If the
> implemented file instance counter is zero I close the file.
> Now more application should use the same DLL and only one instance of this
> DLL should be loaded on the NT/2000 system. Each application using this
DLL
> should be able to write inte the same (!!) file or database at the same
> time. To serialize the calls I could use critical sections.

> But:
> * What I have to do to make sure that each application (process) uses the
> same DLL instancen and instance data?
> * What I have to do that each application (process) is able to write to or
> to read from the same file?

> Regards,
> Roland

> --
> SPLINES-Software, Technical Software Development
> Phone: +43-6246-75385,  Fax: +43-6246-79241

> PGP Fingerprints:
> Roland J. Graf = 0592 DA69 440A E137 4ED5  22AA 3D05 CF60 FABD E14E



Fri, 09 May 2003 03:00:00 GMT  
 ??? Process Shared DLL and Data ???
Hi Adrian,
I tried to call my DLL from two apps and could start the applications. But
because the DLL instance tried always to use the same file, the "second"
file was locked and the access was denied for the second instance.

Ok, now I tried to insert following code from KB article Q109619 in my def
file:

    SECTIONS
          .bss  READ WRITE SHARED
          .data READ WRITE SHARED

and inserted also the linker options:
    -section:.data,rws -section:.bss,rws

Than I compiled and linked my DLL and got the linker warning:
    LNK4092

I ignored this warning and I started two applications which uses my DLL:
The first instance started without problems, the seconds got the third
ASSERT() in the following MFC function:
    inline void* CThreadSlotData::GetThreadValue(int nSlot)
    {
         ASSERT(nSlot != 0 && nSlot < m_nMax);
         ASSERT(m_pSlotData != NULL);
         ASSERT(m_pSlotData[nSlot].dwFlags & SLOT_USED);
         ....

Also I have to write that I tried to use the MFC as static lib and as shared
DLL in my DLL. Both versions had the same warning and ASSERT(...)

* Do you have an idea what could be wrong?

Regards

Roland



Quote:
> Hi,

> Have a look at KB article Q109619.

> Regards,

> --
> Adrian O' Neill
> Remove * in email address to reply



> > I'm writing a DLL to create special logfiles (in ASCII-files and/or MS
Jet
> > database files). Everything is perfect if only one application uses this
> > DLL. The MFC class instances to handle the files are allocated with
new()
> > and I increment a counter in openmyfile(...), if the file with the
> specified
> > name is still open and I decrement the counter in closemyfile(...). If
the
> > implemented file instance counter is zero I close the file.
> > Now more application should use the same DLL and only one instance of
this
> > DLL should be loaded on the NT/2000 system. Each application using this
> DLL
> > should be able to write inte the same (!!) file or database at the same
> > time. To serialize the calls I could use critical sections.

> > But:
> > * What I have to do to make sure that each application (process) uses
the
> > same DLL instancen and instance data?
> > * What I have to do that each application (process) is able to write to
or
> > to read from the same file?

> > Regards,
> > Roland

> > --
> > SPLINES-Software, Technical Software Development
> > Phone: +43-6246-75385,  Fax: +43-6246-79241

> > PGP Fingerprints:
> > Roland J. Graf = 0592 DA69 440A E137 4ED5  22AA 3D05 CF60 FABD E14E



Fri, 09 May 2003 03:00:00 GMT  
 ??? Process Shared DLL and Data ???
Hi,

Quote:
> I tried to call my DLL from two apps and could start the applications. But
> because the DLL instance tried always to use the same file, the "second"
> file was locked and the access was denied for the second instance.

You've got to ensure your logging code is 'atomic', i.e.:
Lock a syncronization object
Open the file
Write your event
Close the file
Unlock object

Do this for each logging event.  Don't open the file at the start of the
DLL.

Quote:

> Than I compiled and linked my DLL and got the linker warning:
>     LNK4092

You may just need to share individual data items then - your DLL may not be
suited for this type of memory sharing.  Have a look at KB article q125677
for information on selective sharing of data.

--
Adrian O' Neill
Remove * in email address to reply



Sat, 10 May 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. DLL with shared data/class not sharing...

2. sharing data between processes

3. Multiple processes sharing data space. --- HELP

4. sharing data between processes

5. Sharing data between processes

6. Sharing data between processes

7. is static data shared between processes

8. Sharing data between processes

9. Sharing Memory across Processes via DLLs

10. Sharing a C++ Object between multiple processes within a Dll

11. VB <-> Dll data sharing

12. Sharing data in .dll usings #pragma data_seg()

 

 
Powered by phpBB® Forum Software