Thread

  1. libpq calls blocking recv when it could not send data enough.

    Ryo Matsumura (Fujitsu) <matsumura.ryo@fujitsu.com> — 2019-11-22T07:32:48Z

    Hi all
    
    Libpq may be blocked by recv without checking data arrival
    when libpq could not send data enough.
    I think it should check by pqReadReady() for avoiding blocking.
    
      Note: I didn't encounter any issue that the pqReadData is blocked.
    
    [src/interfaces/libpq/fe-misc.c]
      pqSendSome(PGconn *conn, int len)
                :
            sent = pqsecure_write(conn, ptr, Min(len, 65536));
            if (sent < 0)
                :
            else
            {
                len -= sent;
            }
            if (len > 0)
            {
                if (pqReadData(conn) < 0)    // read without checking
    
    Must the pqReadData() return without blocking if it could not send enough?
    It may be 'yes', but I think there is no guarantee that there is some data
    and pqReadData() is not blocked.
    
    I think the following is better. How about it?
    <           if (pqReadData(conn) < 0)
    >           if (pqReadReady(conn) && pqReadData(conn) < 0)
    
    Regards
    Ryo Matsumura