Re: Persistent connection extension not freeing connections until server is restarted
| From: | Curt Zirzow | Date: | Thu, 07 Aug 2003 05:20:42 +0000 |
| Subject: | Re: Persistent connection extension not freeing connections until server is restarted | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158605@lists.php.net to get a copy of this message | ||
* Thus wrote Matt Anderson (mda2376@rit.edu):
> Hi all,
>
> I have a fairly advanced question regarding writting modules that create
> persistent resources:
>
You might want to ask this over in php-dev, most people here dont
deal with the internals of php.
> I've written a module very similar to the 'de-facto standard' mysql
> implementation, however its developed a strange bug. Occasionally,
> after working with a persistent connection for a few page calls, php
> seems to 'forget' that its there, without calling the resources' cleanup
> handler. The eventual result, sence the resource opens a socket
> connection to another server (my module binds another API into php), the
> connections will pile up needlessly.
I think it might have to do with this:
hashed_identifier_len = strlen("evopvr___") + strlen(user) +
strlen(passwd) + strlen(host);
hashed_identifier = (char*) emalloc(hashed_identifier_len);
sprintf(hashed_identifier, "evopvr_%s_%s_%s", user, passwd, host);
your emalloc() needs to add +1 to the allocated memory for the \0 at the
end of the string of hashed_identifier. So the next emalloc
call will allocate the spot where your \0 is so you just lost the
end of your string of hashed_identifier.
HTH,
Curt
--
"I used to think I was indecisive, but now I'm not so sure."