Re: LISTEN/NOTIFY problem

From: Dmitri Girski <mitek(at)lizardsw(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: LISTEN/NOTIFY problem
Date: 2009-03-24 05:29:45
Message-ID: daed64560903232229x5c1cfa77pd18f521bbb5673b2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)lizardsw(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joost Kraaijeveld 2009-03-24 07:11:47 Tools for converting XML file with dtd to table?
Previous Message Aimon Bustardo 2009-03-24 04:51:05 Single missing WAL in long sequence..