| From: | "matsumura(dot)ryo(at)fujitsu(dot)com" <matsumura(dot)ryo(at)fujitsu(dot)com> | 
|---|---|
| To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> | 
| Subject: | libpq calls blocking recv when it could not send data enough. | 
| Date: | 2019-11-22 07:32:48 | 
| Message-ID: | OSAPR01MB5027EBEB735E9878AC81EB34E8490@OSAPR01MB5027.jpnprd01.prod.outlook.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Konstantin Knizhnik | 2019-11-22 07:32:51 | Re: Why overhead of SPI is so large? | 
| Previous Message | Antonin Houska | 2019-11-22 07:28:32 | Re: Attempt to consolidate reading of XLOG page |