Re: Flushing large data immediately in pqcomm

  • Jump to comment-1
    Ranier Vilela<ranier.vf@gmail.com>
    Apr 6, 2024, 9:33 PM UTC
    Hi,
    On Fri, 5 Apr 2024 at 03:28, Melih Mutlu
    <m(dot)melihmutlu(at)gmail(dot)com> wrote:
    Right. It was a mistake, forgot to remove that. Fixed it in v5.
    If you don't mind, I have some suggestions for patch v5.
    1. Shouldn't PqSendBufferSize be of type size_t?
    There are several comparisons with other size_t variables.
    static size_t PqSendBufferSize; / Size send buffer /
    I think this would prevent possible overflows.
    2. If PqSendBufferSize is changed to size_t, in the function
    socketputmessagenoblock, the variable which name is required, should
    be changed to size_t as well.
    static void
    socketputmessagenoblock(char msgtype, const char *s, size_t len)
    {
    int res PGUSEDFORASSERTSONLY;
    size_t required;
    3. In the internal_putbytes function, the amout variable could
    have the scope safely reduced.
    else
    {
    size_t amount;
    amount = PqSendBufferSize - PqSendPointer;
    4. In the function internalflushbuffer, the variables named
    bufptr and bufend could be const char * type, like:
    static int
    internalflushbuffer(const char s, size_t start, size_t *end)
    {
    static int lastreportedsend_errno = 0;
    const char bufptr = s + start;
    const char bufend = s + end;
    best regards,
    Ranier Vilela