Re: libpq SSL with non-blocking sockets - Mailing list pgsql-hackers

From Martin Pihlak
Subject Re: libpq SSL with non-blocking sockets
Date
Msg-id 4E2C1627.2030908@gmail.com
Whole thread Raw
In response to Re: libpq SSL with non-blocking sockets  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: libpq SSL with non-blocking sockets
List pgsql-hackers
On 07/16/2011 12:46 AM, Tom Lane wrote:
> I think the direction to move in ought to be to use the existing buffer
> as-is, and have pqCheckOutBufferSpace refuse to enlarge the buffer while
> we are in "write frozen" state.  It should be OK to append data to the
> buffer, though, so long as we remember how much we're allowed to pass to
> SSL_write when we next try to write.

Alternative to freezing the outBuffer would be to set
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER mode during SSL initialisation.
That would enable the buffer address to be changed in-between the
SSL_write calls, so long as the content remains the same. Attached
is a patch that uses the single buffer approach described by Tom, but
with a moving SSL write buffer enabled.

Modifying pqCheckOutBufferSpace is also an option, but it'd break some
(arguably already broken) client applications that don't have proper
retry handling. Notably some versions of psycopg2 have problems with
handling zero return values from PQputCopyData. So ISTM that from
backporting perspective the moving write buffer is a bit safer.

I'll see if I can come up with a test case for the SSL_read retry before
attempting to fix that.

regards,
Martin

Attachment

pgsql-hackers by date:

Previous
From: Stefan Kaltenbrunner
Date:
Subject: Re: pgbench cpu overhead (was Re: lazy vxid locks, v1)
Next
From: Tom Lane
Date:
Subject: Re: pgbench cpu overhead (was Re: lazy vxid locks, v1)