Re: Can a windows DLL have more than one process attached?

From: Mikhail Terekhov <terekhov(at)emc(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Can a windows DLL have more than one process attached?
Date: 2001-11-29 01:17:02
Message-ID: 3C058C8E.3010703@emc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Tom Lane wrote:

> "Ross J. Reedstrom" <reedstrm(at)rice(dot)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

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Mikhail Terekhov 2001-11-29 01:45:42 Re: Can a windows DLL have more than one process attached?
Previous Message Mikhail Terekhov 2001-11-29 00:59:31 Re: Can a windows DLL have more than one process attached?