Skip site navigation (1) Skip section navigation (2)

BUG: possible busy loop when connection is closed while trying toestablish SSL connection

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: pgsql-hackers(at)postgresql(dot)org
Subject: BUG: possible busy loop when connection is closed while trying toestablish SSL connection
Date: 2004-09-23 00:11:02
Message-ID: 1095898262.3552.5.camel@fuji.krosing.net (view raw or flat)
Thread:
Lists: pgsql-hackers
We were bitten by the following bug a few times, when our server tried
to reestablish connections under bad network conditions:


if connection is closed while trying to get response to SSL setup packet
(i.e. conn->status is CONNECTION_SSL_STARTUP), we get a busy loop, as
line 1035 in 8.0.0.beta2:

    if (pqWaitTimed(1, 0, conn, finish_time)  {

tells that there is data to read (returns 0) while actually it is error 
(POLLERR & POLLHUP) and not POLLIN returned from  poll() and 

    nread = recv(conn->sock, &SSLok, 1, 0);

on line 1449 sets nread to 0, as there is in fact nothing to read from a
closed socket
after that the check on line 1462:

    if (nread == 0)
        /* caller failed to wait for data */
        return PGRES_POLLING_READING;

resumes the busy loop

in all other places recv()'ing is done throught pqsecure_read, which
checks for such condition.


I'm not familiar enough with code to suggest a proper fix (and I
quickfix our app by disabling SSL (PGSSLMODE=disable) - the default was
prefer ;), but this may come back to haunt others

--------------
Hannu



Responses

pgsql-hackers by date

Next:From: Neil ConwayDate: 2004-09-23 00:30:45
Subject: Re: CVS configure failure
Previous:From: Robert TreatDate: 2004-09-22 17:19:09
Subject: Re: Variable assignment from dynamic SQL in PL/PgSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group