On 2020-Oct-26, Konstantin Knizhnik wrote:

> +     while (bufptr < bufend || zpq_buffered(PqStream) != 0) /* has more data 
> to flush or unsent data in internal compression buffer */
>       {
> -             int                     r;
> -
> -             r = secure_write(MyProcPort, bufptr, bufend - bufptr);
> -
> -             if (r <= 0)
> +             int             r;
> +             size_t  processed = 0;
> +             size_t  available = bufend - bufptr;
> +             r = PqStream
> +                     ? zpq_write(PqStream, bufptr, available, &processed)
> +                     : secure_write(MyProcPort, bufptr, available);
> +             bufptr += processed;
> +             PqSendStart += processed;

This bit is surprising to me.  I thought the whole zpq_write() thing
should be hidden inside secure_write, so internal_flush would continue
to call just secure_write; and it is that routine's responsibility to
call zpq_write or be_tls_write or secure_raw_write etc according to
compile-time options and socket state.


Reply via email to