Re: Can a windows DLL have more than one process attached? - Mailing list pgsql-interfaces

From Mikhail Terekhov
Subject Re: Can a windows DLL have more than one process attached?
Date
Msg-id 3C058C8E.3010703@emc.com
Whole thread Raw
In response to Re: Can a windows DLL have more than one process attached?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-interfaces
Tom Lane wrote:

> "Ross J. Reedstrom" <reedstrm@rice.edu> writes:
>>    The FreeLibrary function decrements the reference count of the
>>    loaded dynamic-link library (DLL) module.
>>So it's doing the reference counting.
>>
> 
> Yeah, but what increments the reference count?  I could believe the code
> was okay if it did LoadLibraryEx (which presumably increments the count)
> on *every* attach call, but it does that only once, whereas it'll do
> FreeLibrary on each detach.


LoadLibrary increments reference count and FreeLibrary decrements it on every
call not just once.

> 
> However, we may have worse problems.
> 
> 
>>It is not safe to call FreeLibrary or LoadLibraryEx from DllMain.
>>
> 
> This looks ugly, although I'm not sure if it's really a problem for us.

What is the ugliness? We load this data only once at startup and release

on exit.


> I don't see how our pointing to netmsg could create a dependency loop.


There shouldn't be a dependency loop - we load netmsg as data not a code library.

> 
> If this is a problem, a possible answer is not to try to cache the
> netmsg reference at all, but just to load and unload that DLL at the
> single point where it's used.  Since we only use it to translate


That is really ugly in my opinion.

> socket error reports, there's probably no big performance penalty
> involved to do it that way.
> 

Regards,
Mikhail



pgsql-interfaces by date:

Previous
From: Mikhail Terekhov
Date:
Subject: Re: Can a windows DLL have more than one process attached?
Next
From: Mikhail Terekhov
Date:
Subject: Re: Can a windows DLL have more than one process attached?