@@ -578,7 +578,6 @@ pqReadData(PGconn *conn)
578578{
579579int someread = 0 ;
580580int nread ;
581- char sebuf [256 ];
582581
583582if (conn -> sock < 0 )
584583{
@@ -647,11 +646,7 @@ pqReadData(PGconn *conn)
647646if (SOCK_ERRNO == ECONNRESET )
648647gotodefinitelyFailed ;
649648#endif
650- /* in SSL mode, pqsecure_read set the error message */
651- if (conn -> ssl == NULL )
652- printfPQExpBuffer (& conn -> errorMessage ,
653- libpq_gettext ("could not receive data from server: %s\n" ),
654- SOCK_STRERROR (SOCK_ERRNO ,sebuf ,sizeof (sebuf )));
649+ /* pqsecure_read set the error message for us */
655650return -1 ;
656651}
657652if (nread > 0 )
@@ -711,6 +706,11 @@ pqReadData(PGconn *conn)
711706/* ready for read */
712707break ;
713708default :
709+ printfPQExpBuffer (& conn -> errorMessage ,
710+ libpq_gettext (
711+ "server closed the connection unexpectedly\n"
712+ "\tThis probably means the server terminated abnormally\n"
713+ "\tbefore or while processing the request.\n" ));
714714gotodefinitelyFailed ;
715715}
716716
@@ -739,11 +739,7 @@ pqReadData(PGconn *conn)
739739if (SOCK_ERRNO == ECONNRESET )
740740gotodefinitelyFailed ;
741741#endif
742- /* in SSL mode, pqsecure_read set the error message */
743- if (conn -> ssl == NULL )
744- printfPQExpBuffer (& conn -> errorMessage ,
745- libpq_gettext ("could not receive data from server: %s\n" ),
746- SOCK_STRERROR (SOCK_ERRNO ,sebuf ,sizeof (sebuf )));
742+ /* pqsecure_read set the error message for us */
747743return -1 ;
748744}
749745if (nread > 0 )
@@ -754,16 +750,10 @@ pqReadData(PGconn *conn)
754750
755751/*
756752 * OK, we are getting a zero read even though select() says ready. This
757- * means the connection has been closed. Cope.
753+ * means the connection has been closed. Cope. Note that errorMessage
754+ * has been set already.
758755 */
759756definitelyFailed :
760- /* in SSL mode, pqsecure_read set the error message */
761- if (conn -> ssl == NULL )
762- printfPQExpBuffer (& conn -> errorMessage ,
763- libpq_gettext (
764- "server closed the connection unexpectedly\n"
765- "\tThis probably means the server terminated abnormally\n"
766- "\tbefore or while processing the request.\n" ));
767757conn -> status = CONNECTION_BAD ;/* No more connection to backend */
768758pqsecure_close (conn );
769759closesocket (conn -> sock );
@@ -799,7 +789,6 @@ pqSendSome(PGconn *conn, int len)
799789while (len > 0 )
800790{
801791int sent ;
802- char sebuf [256 ];
803792
804793#ifndef WIN32
805794sent = pqsecure_write (conn ,ptr ,len );
@@ -815,11 +804,7 @@ pqSendSome(PGconn *conn, int len)
815804
816805if (sent < 0 )
817806{
818- /*
819- * Anything except EAGAIN/EWOULDBLOCK/EINTR is trouble. If it's
820- * EPIPE or ECONNRESET, assume we've lost the backend connection
821- * permanently.
822- */
807+ /* Anything except EAGAIN/EWOULDBLOCK/EINTR is trouble */
823808switch (SOCK_ERRNO )
824809{
825810#ifdef EAGAIN
@@ -833,17 +818,8 @@ pqSendSome(PGconn *conn, int len)
833818case EINTR :
834819continue ;
835820
836- case EPIPE :
837- #ifdef ECONNRESET
838- case ECONNRESET :
839- #endif
840- /* in SSL mode, pqsecure_write set the error message */
841- if (conn -> ssl == NULL )
842- printfPQExpBuffer (& conn -> errorMessage ,
843- libpq_gettext (
844- "server closed the connection unexpectedly\n"
845- "\tThis probably means the server terminated abnormally\n"
846- "\tbefore or while processing the request.\n" ));
821+ default :
822+ /* pqsecure_write set the error message for us */
847823
848824/*
849825 * We used to close the socket here, but that's a bad idea
@@ -855,16 +831,6 @@ pqSendSome(PGconn *conn, int len)
855831 */
856832conn -> outCount = 0 ;
857833return -1 ;
858-
859- default :
860- /* in SSL mode, pqsecure_write set the error message */
861- if (conn -> ssl == NULL )
862- printfPQExpBuffer (& conn -> errorMessage ,
863- libpq_gettext ("could not send data to server: %s\n" ),
864- SOCK_STRERROR (SOCK_ERRNO ,sebuf ,sizeof (sebuf )));
865- /* We don't assume it's a fatal error... */
866- conn -> outCount = 0 ;
867- return -1 ;
868834}
869835}
870836else