Re: still memory leaks with libpgtcl

Поиск
Список
Период
Сортировка
От ljb
Тема Re: still memory leaks with libpgtcl
Дата
Msg-id avikf6$2f0t$2@news.hub.org
обсуждение исходный текст
Ответ на Re: still memory leaks with libpgtcl  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: still memory leaks with libpgtcl
Список pgsql-interfaces
tgl@sss.pgh.pa.us wrote:
> What we really need to do is reel in a Tcl guru to look at this.
> I think that there is a Tcl bug here somewhere; even if not, we seem
> to need someone who knows the Tcl library inside-and-out to tell us
> what we're doing wrong.
> 
> I don't have the time or interest to pursue this with the Tcl community,
> but perhaps one of you can do it?
> 
>> -#ifdef NOT_USED
>>  #if TCL_MAJOR_VERSION >= 8
>> -    if (connid->notifier_channel != NULL)
>> +    if (connid->notifier_channel != NULL && interp != NULL)
>>          Tcl_UnregisterChannel(NULL, connid->notifier_channel);
>>  #endif
>> -#endif
> 
> Cool solution if it works --- but I'll not accept it unless someone can
> explain to me *why* it fixes the problem, and preferably just where in
> the Tcl documentation this is promised to be a correct solution...

It doesn't fix the problem; it avoids the problem.  The crash happens when
the DriverCloseProc calls UnregisterChannel on shutdown, not on a normal
disconnect. The leak happens when UnregisterChannel is not called on normal
disconnect. The patch avoids the issue by not calling UnregisterChannel if
interp is NULL, as it seems to be only if called during shutdown. So the
patch relies on undocumented behavior inside Tcl - that the
DriverCloseProc() is called with interp==NULL during shutdown.

I agree that something is wrong here, either with how Tcl implements the
unregister/shutdown, or with how libpgtcl uses channels. As I said before,
I don't recommend this patch be applied, except for people who have this
specific problem (long-running program doing frequent connect/disconnects).


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: ljb
Дата:
Сообщение: Re: Shouldn't .pgpass work with anything which uses libpq?
Следующее
От: ljb
Дата:
Сообщение: Re: still memory leaks with libpgtcl