Skip site navigation (1) Skip section navigation (2)

Re: Fix for non-blocking connections in libpq

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bernhard Herzog <bh(at)intevation(dot)de>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Fix for non-blocking connections in libpq
Date: 2002-02-23 02:24:21
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
Your patch has been added to the PostgreSQL unapplied patches list at:

I will try to apply it within the next 48 hours.


Bernhard Herzog wrote:
> Here's a patch against 7.1.3 that fixes a problem with sending larger
> queries over non-blocking connections with libpq. "Larger" here
> basically means that it doesn't fit into the output buffer.
> The basic strategy is to fix pqFlush and pqPutBytes.
> The problem with pqFlush as it stands now is that it returns EOF when an
> error occurs or when not all data could be sent. The latter case is
> clearly not an error for a non-blocking connection but the caller can't
> distringuish it from an error very well.
> The first part of the fix is therefore to fix pqFlush. This is done by
> to renaming it to pqSendSome which only differs from pqFlush in its
> return values to allow the caller to make the above distinction and a
> new pqFlush which is implemented in terms of pqSendSome and behaves
> exactly like the old pqFlush.
> The second part of the fix modifies pqPutBytes to use pqSendSome instead
> of pqFlush and to either send all the data or if not all data can be
> sent on a non-blocking connection to at least put all data into the
> output buffer, enlarging it if necessary. The callers of pqPutBytes
> don't have to be changed because from their point of view pqPutBytes
> behaves like before. It either succeeds in queueing all output data or
> fails with an error.
> I've also added a new API function PQsendSome which analogously to
> PQflush just calls pqSendSome. Programs using non-blocking queries
> should use this new function. The main difference is that this function
> will have to be called repeatedly (calling select() properly in between)
> until all data has been written.
> AFAICT, the code in CVS HEAD hasn't changed with respect to non-blocking
> queries and this fix should work there, too, but I haven't tested that
> yet.

  Bruce Momjian                        |
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

In response to

pgsql-patches by date

Next:From: Bruce MomjianDate: 2002-02-23 02:26:34
Subject: Re: [PATCH] GiST code cleanup
Previous:From: Bruce MomjianDate: 2002-02-23 02:16:10
Subject: Re: enable debugging in jdbc

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group