X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B0A1552896 for ; Tue, 5 Jul 2005 10:48:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98490-05 for ; Tue, 5 Jul 2005 13:48:17 +0000 (GMT) Received: from smtp-vbr1.xs4all.nl (smtp-vbr1.xs4all.nl [194.109.24.21]) by svr1.postgresql.org (Postfix) with ESMTP id 5837D52808 for ; Tue, 5 Jul 2005 10:48:14 -0300 (ADT) Received: from webmail.xs4all.nl (webmail12.xs4all.nl [194.109.22.172]) by smtp-vbr1.xs4all.nl (8.13.3/8.13.3) with ESMTP id j65DmHOq080377 for ; Tue, 5 Jul 2005 15:48:18 +0200 (CEST) (envelope-from jtv@xs4all.nl) Received: from 202.47.227.25 by webmail.xs4all.nl with HTTP; Tue, 5 Jul 2005 15:48:18 +0200 (CEST) Message-ID: <21028.202.47.227.25.1120571298.squirrel@202.47.227.25> Date: Tue, 5 Jul 2005 15:48:18 +0200 (CEST) Subject: libpq and connection failures From: jtv@xs4all.nl To: pgsql-interfaces@postgresql.org User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by XS4ALL Virus Scanner X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.228 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200507/4 X-Sequence-Number: 5640 Is there any reason why pqReadData() (interfaces/libpq/fe-misc.c), if pqsecure_read() fails with an error that isn't special-cased as a transient one, returns -1 but leaves the connection state at CONNECTION_OK? Was this meant to be caught by calling pqReadReady() (which doesn't happen in this case because of the return)? Some libpqxx users with postgres 8.0 installed have observed broken backend connections leading to errors but not updating connection state accordingly. One user unplugged his network cable, leading to a long timeout followed by the error message "could not receive data from server," but libpqxx was unable to diagnose the situation because PQstatus() blithely returned CONNECTION_OK. Doesn't it make more sense in these cases to "goto definitelyFailed" instead of "return -1" as it does now? This occurs in two places BTW, so it may make sense to refactor the function before changing it: the code blocks at labels retry3 and retry4 are completely identical AFAICS except for one small "if" clause (plus a variable is replaced by 0 where it's provably equal to zero). Each is really a switch within a loop, disguised as a nested if through cunning use of goto. Jeroen