Re: PQisBusy() always busy

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: bradg <bg4all(at)me(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: PQisBusy() always busy
Date: 2011-09-12 18:39:35
Message-ID: CAHyXU0xWywhmb8vya+8ekhKo3hn7Oq=hF7fkLMnfRC7RtwHYxw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Mon, Sep 12, 2011 at 12:21 PM, bradg <bg4all(at)me(dot)com> wrote:
> Thanks Merlin.
>
> I added the piece to check PQconsumeInput(). Unfortunately it has not solved
> my problem. It returns 1 indicating "no error" and PQisBusy() still returns
> 1 indefinitely.
>
> Here's the updated code:
>
>
> bool is_result_ready( PGconn * connection )
> {
>    int                 my_socket;
>    struct timeval      timer;
>    fd_set              read_mask;
>
>    if( PQisBusy( connection ) == FALSE )
>        return( TRUE );
>
>    my_socket = PQsocket( connection );
>
>    timer.tv_sec  = (time_t)1;
>    timer.tv_usec = 0;
>
>    FD_ZERO( &read_mask );
>    FD_SET( my_socket, &read_mask );
>
>    if( select( my_socket + 1, &read_mask, NULL, NULL, &timer ) == 0 )
>    {
>        return( FALSE );
>    }
>    else if( FD_ISSET( my_socket, &read_mask ))
>    {
>        if (PQconsumeInput( connection ))
>        {
>            if( PQisBusy( connection ))
>                return( FALSE );
>            else
>                return( TRUE );
>        }
>        else
>        {
>            printf("ERROR with PQconsumeInput(): %s\n",
> PQerrorMessage(connection));
>            return ( FALSE );
>        }
>    }
>    else
>    {
>        return( FALSE );
>    }
> }

hm -- it's working for me. test program (plus some extra logging) attached:

output:
select returned zero
i=0
not busy!
i=1

merlin

Attachment Content-Type Size
async.c text/x-csrc 1.4 KB

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message bradg 2011-09-12 19:04:24 Re: PQisBusy() always busy
Previous Message bradg 2011-09-12 17:21:08 Re: PQisBusy() always busy