Re: PDO and PostgreSQL's LISTEN/NOTIFY
| From: | David J N Begley | Date: | Thu, 26 Oct 2006 03:54:34 +0000 |
| Subject: | Re: PDO and PostgreSQL's LISTEN/NOTIFY | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-4286@lists.php.net to get a copy of this message | ||
On Wed, 25 Oct 2006, Wez Furlong wrote:
> Just noticed this in the docs:
>
> After processing a PGnotify object returned by PQnotifies, be sure to
> free it with free() to avoid a memory leak.
I thought of that but didn't include it for two reasons:
- the old API doesn't do it (at least, not that I saw) and I didn't think
I knew better than the original author; and,
- I was thinking that you shouldn't be trying to deallocate the memory of
a result that you're about to return to a caller, but looking at the
code now we're not actually doing that anyway (ie., the results are
already copied to the return array - right?) so in that sense freeing up
the memory is definitely a good idea.
> And while reading the docs, it looks like it would be really useful
> (at least for my purposes) to be able to efficiently sleep until you
> are notified, so I have a modified version of your patch that adds an
> optional sleep_timeout parameter that specifies a timeout value in
> seconds for a call to select() on the PQsocket() of the connection.
My original effort was just to replicate what the old API did without trying
to be too fancy (given my lack of experience with latest PHP internals), but
the above enhancement would definitely be welcomed by many programmers wanting
to use this feature.
Thanks..