@@ -570,7 +570,6 @@ pqReadData(PGconn *conn)
570
570
{
571
571
int someread = 0 ;
572
572
int nread ;
573
- char sebuf [256 ];
574
573
575
574
if (conn -> sock < 0 )
576
575
{
@@ -639,11 +638,7 @@ pqReadData(PGconn *conn)
639
638
if (SOCK_ERRNO == ECONNRESET )
640
639
goto definitelyFailed ;
641
640
#endif
642
- /* in SSL mode, pqsecure_read set the error message */
643
- if (conn -> ssl == NULL )
644
- printfPQExpBuffer (& conn -> errorMessage ,
645
- libpq_gettext ("could not receive data from server: %s\n" ),
646
- SOCK_STRERROR (SOCK_ERRNO , sebuf , sizeof (sebuf )));
641
+ /* pqsecure_read set the error message for us */
647
642
return -1 ;
648
643
}
649
644
if (nread > 0 )
@@ -703,6 +698,11 @@ pqReadData(PGconn *conn)
703
698
/* ready for read */
704
699
break ;
705
700
default :
701
+ printfPQExpBuffer (& conn -> errorMessage ,
702
+ libpq_gettext (
703
+ "server closed the connection unexpectedly\n"
704
+ "\tThis probably means the server terminated abnormally\n"
705
+ "\tbefore or while processing the request.\n" ));
706
706
goto definitelyFailed ;
707
707
}
708
708
@@ -731,11 +731,7 @@ pqReadData(PGconn *conn)
731
731
if (SOCK_ERRNO == ECONNRESET )
732
732
goto definitelyFailed ;
733
733
#endif
734
- /* in SSL mode, pqsecure_read set the error message */
735
- if (conn -> ssl == NULL )
736
- printfPQExpBuffer (& conn -> errorMessage ,
737
- libpq_gettext ("could not receive data from server: %s\n" ),
738
- SOCK_STRERROR (SOCK_ERRNO , sebuf , sizeof (sebuf )));
734
+ /* pqsecure_read set the error message for us */
739
735
return -1 ;
740
736
}
741
737
if (nread > 0 )
@@ -746,16 +742,10 @@ pqReadData(PGconn *conn)
746
742
747
743
/*
748
744
* OK, we are getting a zero read even though select() says ready. This
749
- * means the connection has been closed. Cope.
745
+ * means the connection has been closed. Cope. Note that errorMessage
746
+ * has been set already.
750
747
*/
751
748
definitelyFailed :
752
- /* in SSL mode, pqsecure_read set the error message */
753
- if (conn -> ssl == NULL )
754
- printfPQExpBuffer (& conn -> errorMessage ,
755
- libpq_gettext (
756
- "server closed the connection unexpectedly\n"
757
- "\tThis probably means the server terminated abnormally\n"
758
- "\tbefore or while processing the request.\n" ));
759
749
conn -> status = CONNECTION_BAD ; /* No more connection to backend */
760
750
pqsecure_close (conn );
761
751
closesocket (conn -> sock );
@@ -791,7 +781,6 @@ pqSendSome(PGconn *conn, int len)
791
781
while (len > 0 )
792
782
{
793
783
int sent ;
794
- char sebuf [256 ];
795
784
796
785
#ifndef WIN32
797
786
sent = pqsecure_write (conn , ptr , len );
@@ -807,11 +796,7 @@ pqSendSome(PGconn *conn, int len)
807
796
808
797
if (sent < 0 )
809
798
{
810
- /*
811
- * Anything except EAGAIN/EWOULDBLOCK/EINTR is trouble. If it's
812
- * EPIPE or ECONNRESET, assume we've lost the backend connection
813
- * permanently.
814
- */
799
+ /* Anything except EAGAIN/EWOULDBLOCK/EINTR is trouble */
815
800
switch (SOCK_ERRNO )
816
801
{
817
802
#ifdef EAGAIN
@@ -825,17 +810,8 @@ pqSendSome(PGconn *conn, int len)
825
810
case EINTR :
826
811
continue ;
827
812
828
- case EPIPE :
829
- #ifdef ECONNRESET
830
- case ECONNRESET :
831
- #endif
832
- /* in SSL mode, pqsecure_write set the error message */
833
- if (conn -> ssl == NULL )
834
- printfPQExpBuffer (& conn -> errorMessage ,
835
- libpq_gettext (
836
- "server closed the connection unexpectedly\n"
837
- "\tThis probably means the server terminated abnormally\n"
838
- "\tbefore or while processing the request.\n" ));
813
+ default :
814
+ /* pqsecure_write set the error message for us */
839
815
840
816
/*
841
817
* We used to close the socket here, but that's a bad idea
@@ -847,16 +823,6 @@ pqSendSome(PGconn *conn, int len)
847
823
*/
848
824
conn -> outCount = 0 ;
849
825
return -1 ;
850
-
851
- default :
852
- /* in SSL mode, pqsecure_write set the error message */
853
- if (conn -> ssl == NULL )
854
- printfPQExpBuffer (& conn -> errorMessage ,
855
- libpq_gettext ("could not send data to server: %s\n" ),
856
- SOCK_STRERROR (SOCK_ERRNO , sebuf , sizeof (sebuf )));
857
- /* We don't assume it's a fatal error... */
858
- conn -> outCount = 0 ;
859
- return -1 ;
860
826
}
861
827
}
862
828
else
0 commit comments