@@ -578,7 +578,6 @@ pqReadData(PGconn *conn)
578
578
{
579
579
int someread = 0 ;
580
580
int nread ;
581
- char sebuf [256 ];
582
581
583
582
if (conn -> sock < 0 )
584
583
{
@@ -647,11 +646,7 @@ pqReadData(PGconn *conn)
647
646
if (SOCK_ERRNO == ECONNRESET )
648
647
goto definitelyFailed ;
649
648
#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 */
655
650
return -1 ;
656
651
}
657
652
if (nread > 0 )
@@ -711,6 +706,11 @@ pqReadData(PGconn *conn)
711
706
/* ready for read */
712
707
break ;
713
708
default :
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" ));
714
714
goto definitelyFailed ;
715
715
}
716
716
@@ -739,11 +739,7 @@ pqReadData(PGconn *conn)
739
739
if (SOCK_ERRNO == ECONNRESET )
740
740
goto definitelyFailed ;
741
741
#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 */
747
743
return -1 ;
748
744
}
749
745
if (nread > 0 )
@@ -754,16 +750,10 @@ pqReadData(PGconn *conn)
754
750
755
751
/*
756
752
* 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.
758
755
*/
759
756
definitelyFailed :
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" ));
767
757
conn -> status = CONNECTION_BAD ; /* No more connection to backend */
768
758
pqsecure_close (conn );
769
759
closesocket (conn -> sock );
@@ -799,7 +789,6 @@ pqSendSome(PGconn *conn, int len)
799
789
while (len > 0 )
800
790
{
801
791
int sent ;
802
- char sebuf [256 ];
803
792
804
793
#ifndef WIN32
805
794
sent = pqsecure_write (conn , ptr , len );
@@ -815,11 +804,7 @@ pqSendSome(PGconn *conn, int len)
815
804
816
805
if (sent < 0 )
817
806
{
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 */
823
808
switch (SOCK_ERRNO )
824
809
{
825
810
#ifdef EAGAIN
@@ -833,17 +818,8 @@ pqSendSome(PGconn *conn, int len)
833
818
case EINTR :
834
819
continue ;
835
820
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 */
847
823
848
824
/*
849
825
* We used to close the socket here, but that's a bad idea
@@ -855,16 +831,6 @@ pqSendSome(PGconn *conn, int len)
855
831
*/
856
832
conn -> outCount = 0 ;
857
833
return -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 ;
868
834
}
869
835
}
870
836
else
0 commit comments