1111 *
1212 *
1313 * IDENTIFICATION
14- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.173 2000/10/21 15:43:26 vadim Exp $
14+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.174 2000/10/24 21:33:52 tgl Exp $
1515 *
1616 * NOTES
1717 *
@@ -803,32 +803,32 @@ ServerLoop(void)
803803 Port * port ;
804804 fd_set rmask ,
805805 wmask ;
806-
807806#ifdef USE_SSL
808- int no_select = 0 ;
809-
807+ bool no_select = false;
810808#endif
811809
812- memmove ((char * ) & rmask , (char * ) & readmask , sizeof (fd_set ));
813- memmove ((char * ) & wmask , (char * ) & writemask , sizeof (fd_set ));
810+ /*
811+ * Wait for something to happen.
812+ */
813+ memcpy ((char * ) & rmask , (char * ) & readmask , sizeof (fd_set ));
814+ memcpy ((char * ) & wmask , (char * ) & writemask , sizeof (fd_set ));
814815
815816#ifdef USE_SSL
816817 for (curr = DLGetHead (PortList ); curr ; curr = DLGetSucc (curr ))
817818 {
818819 if (((Port * ) DLE_VAL (curr ))-> ssl &&
819820 SSL_pending (((Port * ) DLE_VAL (curr ))-> ssl ) > 0 )
820821 {
821- no_select = 1 ;
822+ no_select = true ;
822823 break ;
823824 }
824825 }
825- PG_SETMASK (& UnBlockSig );
826826 if (no_select )
827827 FD_ZERO (& rmask ); /* So we don't accept() anything below */
828- else
829- #else
830- PG_SETMASK (& UnBlockSig );
831828#endif
829+
830+ PG_SETMASK (& UnBlockSig );
831+
832832 if (select (nSockets , & rmask , & wmask , (fd_set * ) NULL ,
833833 (struct timeval * ) NULL ) < 0 )
834834 {
@@ -838,6 +838,21 @@ ServerLoop(void)
838838 progname , strerror (errno ));
839839 return STATUS_ERROR ;
840840 }
841+
842+ /*
843+ * Block all signals until we wait again
844+ */
845+ PG_SETMASK (& BlockSig );
846+
847+ /*
848+ * Respond to signals, if needed
849+ */
850+ if (got_SIGHUP )
851+ {
852+ got_SIGHUP = false;
853+ ProcessConfigFile (PGC_SIGHUP );
854+ }
855+
841856 /*
842857 * Select a random seed at the time of first receiving a request.
843858 */
@@ -856,11 +871,8 @@ ServerLoop(void)
856871 }
857872
858873 /*
859- * Block all signals
874+ * new connection pending on our well-known port's socket?
860875 */
861- PG_SETMASK (& BlockSig );
862-
863- /* new connection pending on our well-known port's socket */
864876
865877#ifdef HAVE_UNIX_SOCKETS
866878 if (ServerSock_UNIX != INVALID_SOCK &&
@@ -893,21 +905,12 @@ ServerLoop(void)
893905 Port * port = (Port * ) DLE_VAL (curr );
894906 int status = STATUS_OK ;
895907 Dlelem * next ;
896- int readyread = 0 ;
897908
909+ if (FD_ISSET (port -> sock , & rmask )
898910#ifdef USE_SSL
899- if (port -> ssl )
900- {
901- if (SSL_pending (port -> ssl ) ||
902- FD_ISSET (port -> sock , & rmask ))
903- readyread = 1 ;
904- }
905- else
911+ || (port -> ssl && SSL_pending (port -> ssl ))
906912#endif
907- if (FD_ISSET (port -> sock , & rmask ))
908- readyread = 1 ;
909-
910- if (readyread )
913+ )
911914 {
912915 if (DebugLvl > 1 )
913916 fprintf (stderr , "%s: ServerLoop:\t\thandling reading %d\n" ,
@@ -997,13 +1000,7 @@ ServerLoop(void)
9971000 }
9981001
9991002 curr = next ;
1000- }
1001-
1002- if (got_SIGHUP )
1003- {
1004- got_SIGHUP = false;
1005- ProcessConfigFile (PGC_SIGHUP );
1006- }
1003+ } /* loop over active ports */
10071004 }
10081005}
10091006
@@ -1269,7 +1266,6 @@ reset_shared(int port)
12691266static void
12701267SIGHUP_handler (SIGNAL_ARGS )
12711268{
1272- got_SIGHUP = true;
12731269 if (Shutdown > SmartShutdown )
12741270 return ;
12751271 got_SIGHUP = true;
0 commit comments