@@ -619,85 +619,85 @@ ws_sigterm_handler(SIGNAL_ARGS)
619619void
620620webserver_worker_main (Datum unused )
621621{
622- YBCInitThreading ();
623- /*
624- * We call YBCInit here so that HandleYBStatus can correctly report potential error.
625- */
626- HandleYBStatus (YBCInit (NULL /* argv[0] */ , palloc , NULL /* cstring_to_text_with_len_fn */ ));
622+ YBCInitThreading ();
623+ /*
624+ * We call YBCInit here so that HandleYBStatus can correctly report potential error.
625+ */
626+ HandleYBStatus (YBCInit (NULL /* argv[0] */ , palloc , NULL /* cstring_to_text_with_len_fn */ ));
627627
628- backendStatusArray = getBackendStatusArray ();
628+ backendStatusArray = getBackendStatusArray ();
629629
630- BackgroundWorkerUnblockSignals ();
630+ BackgroundWorkerUnblockSignals ();
631631
632- /*
633- * Assert that shared memory is allocated to backendStatusArray before this webserver
634- * is started.
635- */
636- if (!backendStatusArray )
637- ereport (FATAL ,
638- (errcode (ERRCODE_INTERNAL_ERROR ),
639- errmsg ("Shared memory not allocated to BackendStatusArray before starting YSQL webserver" )));
632+ /*
633+ * Assert that shared memory is allocated to backendStatusArray before this webserver
634+ * is started.
635+ */
636+ if (!backendStatusArray )
637+ ereport (FATAL ,
638+ (errcode (ERRCODE_INTERNAL_ERROR ),
639+ errmsg ("Shared memory not allocated to BackendStatusArray before starting YSQL webserver" )));
640640
641- webserver = CreateWebserver (ListenAddresses , port );
641+ webserver = CreateWebserver (ListenAddresses , port );
642642
643- RegisterMetrics (ybpgm_table , num_entries , metric_node_name );
643+ RegisterMetrics (ybpgm_table , num_entries , metric_node_name );
644644
645- postgresCallbacks callbacks ;
646- callbacks .pullRpczEntries = pullRpczEntries ;
647- callbacks .freeRpczEntries = freeRpczEntries ;
648- callbacks .getTimestampTz = GetCurrentTimestamp ;
649- callbacks .getTimestampTzDiffMs = getElapsedMs ;
650- callbacks .getTimestampTzToStr = timestamptz_to_str ;
645+ postgresCallbacks callbacks ;
646+ callbacks .pullRpczEntries = pullRpczEntries ;
647+ callbacks .freeRpczEntries = freeRpczEntries ;
648+ callbacks .getTimestampTz = GetCurrentTimestamp ;
649+ callbacks .getTimestampTzDiffMs = getElapsedMs ;
650+ callbacks .getTimestampTzToStr = timestamptz_to_str ;
651651
652- YbConnectionMetrics conn_metrics ;
653- conn_metrics .max_conn = & MaxConnections ;
654- conn_metrics .too_many_conn = yb_too_many_conn ;
655- conn_metrics .new_conn = yb_new_conn ;
652+ YbConnectionMetrics conn_metrics ;
653+ conn_metrics .max_conn = & MaxConnections ;
654+ conn_metrics .too_many_conn = yb_too_many_conn ;
655+ conn_metrics .new_conn = yb_new_conn ;
656656
657- RegisterRpczEntries (& callbacks , & num_backends , & rpcz , & conn_metrics );
658- HandleYBStatus (StartWebserver (webserver ));
657+ RegisterRpczEntries (& callbacks , & num_backends , & rpcz , & conn_metrics );
658+ HandleYBStatus (StartWebserver (webserver ));
659659
660660 pqsignal (SIGHUP , ws_sighup_handler );
661661 pqsignal (SIGTERM , ws_sigterm_handler );
662662
663- SetWebserverConfig (webserver , log_accesses , log_tcmalloc_stats ,
664- webserver_profiler_sample_freq_bytes );
665-
666- int rc ;
667- while (!got_SIGTERM )
668- {
669- rc = WaitLatch (MyLatch , WL_LATCH_SET | WL_POSTMASTER_DEATH , -1 , PG_WAIT_EXTENSION );
670- ResetLatch (MyLatch );
663+ SetWebserverConfig (webserver , log_accesses , log_tcmalloc_stats ,
664+ webserver_profiler_sample_freq_bytes );
671665
672- if (rc & WL_POSTMASTER_DEATH )
673- break ;
674-
675- if (got_SIGHUP )
676- {
677- got_SIGHUP = false;
678- ProcessConfigFile (PGC_SIGHUP );
679- SetWebserverConfig (webserver , log_accesses , log_tcmalloc_stats ,
680- webserver_profiler_sample_freq_bytes );
681- }
682- }
683-
684- if (rpcz != NULL && ybrpczMemoryContext != NULL )
685- {
686- MemoryContext oldcontext = MemoryContextSwitchTo (ybrpczMemoryContext );
687- pfree (rpcz );
688- MemoryContextSwitchTo (oldcontext );
689- }
666+ int rc ;
667+ while (!got_SIGTERM )
668+ {
669+ rc = WaitLatch (MyLatch , WL_LATCH_SET | WL_POSTMASTER_DEATH , -1 , PG_WAIT_EXTENSION );
670+ ResetLatch (MyLatch );
671+
672+ if (rc & WL_POSTMASTER_DEATH )
673+ break ;
674+
675+ if (got_SIGHUP )
676+ {
677+ got_SIGHUP = false;
678+ ProcessConfigFile (PGC_SIGHUP );
679+ SetWebserverConfig (webserver , log_accesses , log_tcmalloc_stats ,
680+ webserver_profiler_sample_freq_bytes );
681+ }
682+ }
690683
691684 if (webserver )
692685 {
693686 DestroyWebserver (webserver );
694687 webserver = NULL ;
695688 }
696689
697- if (rc & WL_POSTMASTER_DEATH )
698- proc_exit (1 );
690+ if (rpcz != NULL && ybrpczMemoryContext != NULL )
691+ {
692+ MemoryContext oldcontext = MemoryContextSwitchTo (ybrpczMemoryContext );
693+ pfree (rpcz );
694+ MemoryContextSwitchTo (oldcontext );
695+ }
696+
697+ if (rc & WL_POSTMASTER_DEATH )
698+ proc_exit (1 );
699699
700- proc_exit (0 );
700+ proc_exit (0 );
701701}
702702
703703/*
0 commit comments