Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6afa2ae

Browse files
committed
Clean up broken test for whether to wait for input in SSL case.
Per discussion with Magnus Hagander.
1 parent87968e3 commit6afa2ae

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.174 2000/10/24 21:33:52 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.175 2000/10/25 22:27:25 tgl Exp $
1515
*
1616
* NOTES
1717
*
@@ -262,7 +262,7 @@ static void InitSSL(void);
262262
#endif
263263

264264
#ifdefCYR_RECODE
265-
voidGetCharSetByHost(char*,int,char*);
265+
externvoidGetCharSetByHost(char*,int,char*);
266266

267267
#endif
268268

@@ -803,34 +803,38 @@ ServerLoop(void)
803803
Port*port;
804804
fd_setrmask,
805805
wmask;
806+
structtimeval*timeout= (structtimeval*)NULL;
806807
#ifdefUSE_SSL
807-
boolno_select= false;
808-
#endif
808+
structtimevaltimeout_tv;
809809

810810
/*
811-
* Wait for something to happen.
811+
* If we are using SSL, there may be input data already read and
812+
* pending in SSL's input buffers. If so, check for additional
813+
* input from other clients, but don't delay before processing.
812814
*/
813-
memcpy((char*)&rmask, (char*)&readmask,sizeof(fd_set));
814-
memcpy((char*)&wmask, (char*)&writemask,sizeof(fd_set));
815-
816-
#ifdefUSE_SSL
817815
for (curr=DLGetHead(PortList);curr;curr=DLGetSucc(curr))
818816
{
819-
if (((Port*)DLE_VAL(curr))->ssl&&
820-
SSL_pending(((Port*)DLE_VAL(curr))->ssl)>0)
817+
Port*port= (Port*)DLE_VAL(curr);
818+
819+
if (port->ssl&&SSL_pending(port->ssl))
821820
{
822-
no_select= true;
821+
timeout_tv.tv_sec=0;
822+
timeout_tv.tv_usec=0;
823+
timeout=&timeout_tv;
823824
break;
824825
}
825826
}
826-
if (no_select)
827-
FD_ZERO(&rmask);/* So we don't accept() anything below */
828827
#endif
829828

829+
/*
830+
* Wait for something to happen.
831+
*/
832+
memcpy((char*)&rmask, (char*)&readmask,sizeof(fd_set));
833+
memcpy((char*)&wmask, (char*)&writemask,sizeof(fd_set));
834+
830835
PG_SETMASK(&UnBlockSig);
831836

832-
if (select(nSockets,&rmask,&wmask, (fd_set*)NULL,
833-
(structtimeval*)NULL)<0)
837+
if (select(nSockets,&rmask,&wmask, (fd_set*)NULL,timeout)<0)
834838
{
835839
if (errno==EINTR||errno==EWOULDBLOCK)
836840
continue;
@@ -894,8 +898,10 @@ ServerLoop(void)
894898
(void*)port);
895899
}
896900

897-
/* Build up new masks for select(). */
898-
901+
/*
902+
* Scan active ports, processing any available input. While we
903+
* are at it, build up new masks for next select().
904+
*/
899905
nSockets=initMasks(&readmask,&writemask);
900906

901907
curr=DLGetHead(PortList);
@@ -946,7 +952,7 @@ ServerLoop(void)
946952
/*
947953
* Can't start backend if max backend count is exceeded.
948954
*
949-
* The same whenshutdowningdata base.
955+
* The same when data base is in startup/shutdown mode.
950956
*/
951957
if (Shutdown>NoShutdown)
952958
PacketSendError(&port->pktInfo,
@@ -966,8 +972,8 @@ ServerLoop(void)
966972
/*
967973
* If the backend start fails then keep the connection
968974
* open to report it. Otherwise, pretend there is an
969-
* error to closethe connection which will now be
970-
* managed by the backend.
975+
* error to closeour descriptor for the connection,
976+
*which will now bemanaged by the backend.
971977
*/
972978
if (BackendStartup(port)!=STATUS_OK)
973979
PacketSendError(&port->pktInfo,
@@ -1067,22 +1073,23 @@ readStartupPacket(void *arg, PacketLen len, void *pkt)
10671073
charSSLok;
10681074

10691075
#ifdefUSE_SSL
1070-
if (!EnableSSL||port->laddr.sa.sa_family!=AF_INET)
1071-
/* No SSL when disabled or on Unix sockets */
1072-
SSLok='N';
1076+
/* No SSL when disabled or on Unix sockets */
1077+
if (!EnableSSL||port->laddr.sa.sa_family!=AF_INET)
1078+
SSLok='N';
10731079
else
1074-
SSLok='S';/* Support for SSL */
1080+
SSLok='S';/* Support for SSL */
10751081
#else
10761082
SSLok='N';/* No support for SSL */
10771083
#endif
10781084
if (send(port->sock,&SSLok,1,0)!=1)
10791085
{
10801086
perror("Failed to send SSL negotiation response");
1081-
returnSTATUS_ERROR;/* Close connection */
1087+
returnSTATUS_ERROR;/* Close connection */
10821088
}
10831089

10841090
#ifdefUSE_SSL
1085-
if (SSLok=='S') {
1091+
if (SSLok=='S')
1092+
{
10861093
if (!(port->ssl=SSL_new(SSL_context))||
10871094
!SSL_set_fd(port->ssl,port->sock)||
10881095
SSL_accept(port->ssl) <=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp