Re: LISTEN/NOTIFY problem - Mailing list pgsql-general

From Dmitri Girski
Subject Re: LISTEN/NOTIFY problem
Date
Msg-id daed64560903232229x5c1cfa77pd18f521bbb5673b2@mail.gmail.com
Whole thread Raw
In response to LISTEN/NOTIFY problem  (Dmitri Girski <mitek@lizardsw.com>)
List pgsql-general
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 <mitek@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:

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

pgsql-general by date:

Previous
From: Torsten Zühlsdorff
Date:
Subject: Fulltext: problem with english words in german text
Next
From: Berdam
Date:
Subject: Res: [win32] 8.3.5 -> 8.3.7 install trouble