Thread

  1. Re: libpq SSL with non-blocking sockets

    Martin Pihlak <martin.pihlak@gmail.com> — 2011-07-24T12:55:03Z

    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