@@ -74,10 +74,10 @@ alloc_history(History *observations, int count)
7474static void
7575realloc_history (History * observations ,int count )
7676{
77- HistoryItem * newitems ;
78- int copyCount ,
79- i ,
80- j ;
77+ HistoryItem * newitems ;
78+ int copyCount ,
79+ i ,
80+ j ;
8181
8282/* Allocate new array for history */
8383newitems = (HistoryItem * )palloc0 (sizeof (HistoryItem )* count );
@@ -115,7 +115,8 @@ realloc_history(History *observations, int count)
115115static void
116116handle_sigterm (SIGNAL_ARGS )
117117{
118- int save_errno = errno ;
118+ int save_errno = errno ;
119+
119120shutdown_requested = true;
120121if (MyProc )
121122SetLatch (& MyProc -> procLatch );
@@ -150,7 +151,7 @@ probe_waits(History *observations, HTAB *profile_hash,
150151{
151152int i ,
152153newSize ;
153- TimestampTz ts = GetCurrentTimestamp ();
154+ TimestampTz ts = GetCurrentTimestamp ();
154155
155156/* Realloc waits history if needed */
156157newSize = pgws_historySize ;
@@ -161,9 +162,9 @@ probe_waits(History *observations, HTAB *profile_hash,
161162LWLockAcquire (ProcArrayLock ,LW_SHARED );
162163for (i = 0 ;i < ProcGlobal -> allProcCount ;i ++ )
163164{
164- HistoryItem item ,
165- * observation ;
166- PGPROC * proc = & ProcGlobal -> allProcs [i ];
165+ HistoryItem item ,
166+ * observation ;
167+ PGPROC * proc = & ProcGlobal -> allProcs [i ];
167168
168169if (!pgws_should_sample_proc (proc ,& item .pid ,& item .wait_event_info ))
169170continue ;
@@ -185,8 +186,8 @@ probe_waits(History *observations, HTAB *profile_hash,
185186/* Write to the profile if needed */
186187if (write_profile )
187188{
188- ProfileItem * profileItem ;
189- bool found ;
189+ ProfileItem * profileItem ;
190+ bool found ;
190191
191192if (!profile_pid )
192193item .pid = 0 ;
@@ -207,9 +208,9 @@ probe_waits(History *observations, HTAB *profile_hash,
207208static void
208209send_history (History * observations ,shm_mq_handle * mqh )
209210{
210- Size count ,
211- i ;
212- shm_mq_result mq_result ;
211+ Size count ,
212+ i ;
213+ shm_mq_result mq_result ;
213214
214215if (observations -> wraparound )
215216count = observations -> count ;
@@ -227,10 +228,10 @@ send_history(History *observations, shm_mq_handle *mqh)
227228for (i = 0 ;i < count ;i ++ )
228229{
229230mq_result = shm_mq_send_compat (mqh ,
230- sizeof (HistoryItem ),
231- & observations -> items [i ],
232- false,
233- true);
231+ sizeof (HistoryItem ),
232+ & observations -> items [i ],
233+ false,
234+ true);
234235if (mq_result == SHM_MQ_DETACHED )
235236{
236237ereport (WARNING ,
@@ -247,10 +248,10 @@ send_history(History *observations, shm_mq_handle *mqh)
247248static void
248249send_profile (HTAB * profile_hash ,shm_mq_handle * mqh )
249250{
250- HASH_SEQ_STATUS scan_status ;
251- ProfileItem * item ;
252- Size count = hash_get_num_entries (profile_hash );
253- shm_mq_result mq_result ;
251+ HASH_SEQ_STATUS scan_status ;
252+ ProfileItem * item ;
253+ Size count = hash_get_num_entries (profile_hash );
254+ shm_mq_result mq_result ;
254255
255256mq_result = shm_mq_send_compat (mqh ,sizeof (count ),& count , false, true);
256257if (mq_result == SHM_MQ_DETACHED )
@@ -282,7 +283,7 @@ send_profile(HTAB *profile_hash, shm_mq_handle *mqh)
282283static HTAB *
283284make_profile_hash ()
284285{
285- HASHCTL hash_ctl ;
286+ HASHCTL hash_ctl ;
286287
287288hash_ctl .hash = tag_hash ;
288289hash_ctl .hcxt = TopMemoryContext ;
@@ -303,8 +304,8 @@ make_profile_hash()
303304static int64
304305millisecs_diff (TimestampTz tz1 ,TimestampTz tz2 )
305306{
306- long secs ;
307- int microsecs ;
307+ long secs ;
308+ int microsecs ;
308309
309310TimestampDifference (tz1 ,tz2 ,& secs ,& microsecs );
310311
@@ -318,13 +319,13 @@ millisecs_diff(TimestampTz tz1, TimestampTz tz2)
318319void
319320pgws_collector_main (Datum main_arg )
320321{
321- HTAB * profile_hash = NULL ;
322- History observations ;
323- MemoryContext old_context ,
324- collector_context ;
325- TimestampTz current_ts ,
326- history_ts ,
327- profile_ts ;
322+ HTAB * profile_hash = NULL ;
323+ History observations ;
324+ MemoryContext old_context ,
325+ collector_context ;
326+ TimestampTz current_ts ,
327+ history_ts ,
328+ profile_ts ;
328329
329330/*
330331 * Establish signal handlers.
@@ -358,7 +359,7 @@ pgws_collector_main(Datum main_arg)
358359
359360CurrentResourceOwner = ResourceOwnerCreate (NULL ,"pg_wait_sampling collector" );
360361collector_context = AllocSetContextCreate (TopMemoryContext ,
361- "pg_wait_sampling context" ,ALLOCSET_DEFAULT_SIZES );
362+ "pg_wait_sampling context" ,ALLOCSET_DEFAULT_SIZES );
362363old_context = MemoryContextSwitchTo (collector_context );
363364alloc_history (& observations ,pgws_historySize );
364365MemoryContextSwitchTo (old_context );
@@ -370,12 +371,12 @@ pgws_collector_main(Datum main_arg)
370371
371372while (1 )
372373{
373- int rc ;
374- shm_mq_handle * mqh ;
375- int64 history_diff ,
376- profile_diff ;
377- bool write_history ,
378- write_profile ;
374+ int rc ;
375+ shm_mq_handle * mqh ;
376+ int64 history_diff ,
377+ profile_diff ;
378+ bool write_history ,
379+ write_profile ;
379380
380381/* We need an explicit call for at least ProcSignal notifications. */
381382CHECK_FOR_INTERRUPTS ();
@@ -392,8 +393,8 @@ pgws_collector_main(Datum main_arg)
392393history_diff = millisecs_diff (history_ts ,current_ts );
393394profile_diff = millisecs_diff (profile_ts ,current_ts );
394395
395- write_history = (history_diff >= (int64 )pgws_historyPeriod );
396- write_profile = (profile_diff >= (int64 )pgws_profilePeriod );
396+ write_history = (history_diff >= (int64 )pgws_historyPeriod );
397+ write_profile = (profile_diff >= (int64 )pgws_profilePeriod );
397398
398399if (write_history || write_profile )
399400{
@@ -422,8 +423,8 @@ pgws_collector_main(Datum main_arg)
422423 * shared memory.
423424 */
424425rc = WaitLatch (& MyProc -> procLatch ,WL_LATCH_SET |WL_TIMEOUT |WL_POSTMASTER_DEATH ,
425- Min (pgws_historyPeriod - (int )history_diff ,
426- pgws_historyPeriod - (int )profile_diff ),PG_WAIT_EXTENSION );
426+ Min (pgws_historyPeriod - (int )history_diff ,
427+ pgws_historyPeriod - (int )profile_diff ),PG_WAIT_EXTENSION );
427428
428429if (rc & WL_POSTMASTER_DEATH )
429430proc_exit (1 );
@@ -444,7 +445,7 @@ pgws_collector_main(Datum main_arg)
444445
445446if (request == HISTORY_REQUEST || request == PROFILE_REQUEST )
446447{
447- shm_mq_result mq_result ;
448+ shm_mq_result mq_result ;
448449
449450/* Send history or profile */
450451shm_mq_set_sender (pgws_collector_mq ,MyProc );