Thank you guys for your replies!
It is definitely something wrong with my code, here is the thread which does
the listening:
http://mitek.id.au/flex/DBListener.cpp
The rest of application is fairly big and does not relate to the database.
For libpq calls I am using the SPTK (http://sptk.net) library. I've added
additional wrappers for PGsocket, PQfreemem.
So the current code works without any problem, but as soon as I remove
subcribe() function from the loop and call it just once, daemon eventually
will stop getting notifications.
There is nothing wrong with the socket or db connections - all possible
error will be logged.
Cheers,
Dmitri.
On Mon, Mar 23, 2009 at 10:00 PM, Dmitri Girski mi...@lizardsw.com wrote:
Hi everybody,
I've got a weird problem with LISTEN/NOTIFY.
My C++ app subscribes for the notifications, just like in libpq examples:
http://www.postgresql.org/docs/8.3/static/libpq-example.html
The only difference, that I am setting the timeout on select just to check
if application wants to exit.
//open session
//subscribe
while(!exit)
{
sock = PGsocket(conn)
res = select(sock);
if (res)
//check if it timeout
//or if there was a notification
}
The problem that I am facing is that after some time notifications stop
coming.
select() returns on timeout and nothing else.
Just as a test a included UNLISTEN/LISTEN sequence into the loop, so after
timeout or event application re-subscribes. And this helps.
The question is, what I am doing wrong with the code in the first place?
Any help is appreciated.
Cheers,
Dmitri.
--
@Gmail
--
@Gmail