File tree 15 files changed +6
-87
lines changed
15 files changed +6
-87
lines changed Original file line number Diff line number Diff line change @@ -1007,18 +1007,10 @@ MemoryContextSwitchTo(MemoryContext context)
1007
1007
static void
1008
1008
handle_sighup(SIGNAL_ARGS)
1009
1009
{
1010
- int save_errno = errno;
1011
-
1012
1010
got_SIGHUP = true;
1013
1011
SetLatch(MyLatch);
1014
-
1015
- errno = save_errno;
1016
1012
}
1017
1013
</programlisting>
1018
- <varname>errno</varname> is saved and restored because
1019
- <function>SetLatch()</function> might change it. If that were not done
1020
- interrupted code that's currently inspecting <varname>errno</varname> might see the wrong
1021
- value.
1022
1014
</para>
1023
1015
</simplesect>
1024
1016
Original file line number Diff line number Diff line change @@ -1410,12 +1410,8 @@ AutoVacWorkerFailed(void)
1410
1410
static void
1411
1411
avl_sigusr2_handler (SIGNAL_ARGS )
1412
1412
{
1413
- int save_errno = errno ;
1414
-
1415
1413
got_SIGUSR2 = true;
1416
1414
SetLatch (MyLatch );
1417
-
1418
- errno = save_errno ;
1419
1415
}
1420
1416
1421
1417
Original file line number Diff line number Diff line change @@ -852,15 +852,11 @@ IsCheckpointOnSchedule(double progress)
852
852
static void
853
853
ReqCheckpointHandler (SIGNAL_ARGS )
854
854
{
855
- int save_errno = errno ;
856
-
857
855
/*
858
856
* The signaling process should have set ckpt_flags nonzero, so all we
859
857
* need do is ensure that our main loop gets kicked out of any wait.
860
858
*/
861
859
SetLatch (MyLatch );
862
-
863
- errno = save_errno ;
864
860
}
865
861
866
862
Original file line number Diff line number Diff line change @@ -60,12 +60,8 @@ HandleMainLoopInterrupts(void)
60
60
void
61
61
SignalHandlerForConfigReload (SIGNAL_ARGS )
62
62
{
63
- int save_errno = errno ;
64
-
65
63
ConfigReloadPending = true;
66
64
SetLatch (MyLatch );
67
-
68
- errno = save_errno ;
69
65
}
70
66
71
67
/*
@@ -108,10 +104,6 @@ SignalHandlerForCrashExit(SIGNAL_ARGS)
108
104
void
109
105
SignalHandlerForShutdownRequest (SIGNAL_ARGS )
110
106
{
111
- int save_errno = errno ;
112
-
113
107
ShutdownRequestPending = true;
114
108
SetLatch (MyLatch );
115
-
116
- errno = save_errno ;
117
109
}
Original file line number Diff line number Diff line change @@ -283,13 +283,9 @@ PgArchWakeup(void)
283
283
static void
284
284
pgarch_waken_stop (SIGNAL_ARGS )
285
285
{
286
- int save_errno = errno ;
287
-
288
286
/* set flag to do a final cycle and shut down afterwards */
289
287
ready_to_stop = true;
290
288
SetLatch (MyLatch );
291
-
292
- errno = save_errno ;
293
289
}
294
290
295
291
/*
Original file line number Diff line number Diff line change @@ -2612,12 +2612,8 @@ InitProcessGlobals(void)
2612
2612
static void
2613
2613
handle_pm_pmsignal_signal (SIGNAL_ARGS )
2614
2614
{
2615
- int save_errno = errno ;
2616
-
2617
2615
pending_pm_pmsignal = true;
2618
2616
SetLatch (MyLatch );
2619
-
2620
- errno = save_errno ;
2621
2617
}
2622
2618
2623
2619
/*
@@ -2626,12 +2622,8 @@ handle_pm_pmsignal_signal(SIGNAL_ARGS)
2626
2622
static void
2627
2623
handle_pm_reload_request_signal (SIGNAL_ARGS )
2628
2624
{
2629
- int save_errno = errno ;
2630
-
2631
2625
pending_pm_reload_request = true;
2632
2626
SetLatch (MyLatch );
2633
-
2634
- errno = save_errno ;
2635
2627
}
2636
2628
2637
2629
/*
@@ -2711,8 +2703,6 @@ process_pm_reload_request(void)
2711
2703
static void
2712
2704
handle_pm_shutdown_request_signal (SIGNAL_ARGS )
2713
2705
{
2714
- int save_errno = errno ;
2715
-
2716
2706
switch (postgres_signal_arg )
2717
2707
{
2718
2708
case SIGTERM :
@@ -2729,8 +2719,6 @@ handle_pm_shutdown_request_signal(SIGNAL_ARGS)
2729
2719
break ;
2730
2720
}
2731
2721
SetLatch (MyLatch );
2732
-
2733
- errno = save_errno ;
2734
2722
}
2735
2723
2736
2724
/*
@@ -2890,12 +2878,8 @@ process_pm_shutdown_request(void)
2890
2878
static void
2891
2879
handle_pm_child_exit_signal (SIGNAL_ARGS )
2892
2880
{
2893
- int save_errno = errno ;
2894
-
2895
2881
pending_pm_child_exit = true;
2896
2882
SetLatch (MyLatch );
2897
-
2898
- errno = save_errno ;
2899
2883
}
2900
2884
2901
2885
/*
Original file line number Diff line number Diff line change @@ -95,32 +95,22 @@ static void StartupProcExit(int code, Datum arg);
95
95
static void
96
96
StartupProcTriggerHandler (SIGNAL_ARGS )
97
97
{
98
- int save_errno = errno ;
99
-
100
98
promote_signaled = true;
101
99
WakeupRecovery ();
102
-
103
- errno = save_errno ;
104
100
}
105
101
106
102
/* SIGHUP: set flag to re-read config file at next convenient time */
107
103
static void
108
104
StartupProcSigHupHandler (SIGNAL_ARGS )
109
105
{
110
- int save_errno = errno ;
111
-
112
106
got_SIGHUP = true;
113
107
WakeupRecovery ();
114
-
115
- errno = save_errno ;
116
108
}
117
109
118
110
/* SIGTERM: set flag to abort redo and exit */
119
111
static void
120
112
StartupProcShutdownHandler (SIGNAL_ARGS )
121
113
{
122
- int save_errno = errno ;
123
-
124
114
if (in_restore_command )
125
115
{
126
116
/*
@@ -139,8 +129,6 @@ StartupProcShutdownHandler(SIGNAL_ARGS)
139
129
else
140
130
shutdown_requested = true;
141
131
WakeupRecovery ();
142
-
143
- errno = save_errno ;
144
132
}
145
133
146
134
/*
Original file line number Diff line number Diff line change @@ -1642,10 +1642,6 @@ RemoveLogrotateSignalFiles(void)
1642
1642
static void
1643
1643
sigUsr1Handler (SIGNAL_ARGS )
1644
1644
{
1645
- int save_errno = errno ;
1646
-
1647
1645
rotation_requested = true;
1648
1646
SetLatch (MyLatch );
1649
-
1650
- errno = save_errno ;
1651
1647
}
Original file line number Diff line number Diff line change @@ -3476,12 +3476,8 @@ HandleWalSndInitStopping(void)
3476
3476
static void
3477
3477
WalSndLastCycleHandler (SIGNAL_ARGS )
3478
3478
{
3479
- int save_errno = errno ;
3480
-
3481
3479
got_SIGUSR2 = true;
3482
3480
SetLatch (MyLatch );
3483
-
3484
- errno = save_errno ;
3485
3481
}
3486
3482
3487
3483
/* Set up signal handlers */
Original file line number Diff line number Diff line change @@ -2243,12 +2243,8 @@ GetNumRegisteredWaitEvents(WaitEventSet *set)
2243
2243
static void
2244
2244
latch_sigurg_handler (SIGNAL_ARGS )
2245
2245
{
2246
- int save_errno = errno ;
2247
-
2248
2246
if (waiting )
2249
2247
sendSelfPipeByte ();
2250
-
2251
- errno = save_errno ;
2252
2248
}
2253
2249
2254
2250
/* Send one byte to the self-pipe, to wake up WaitLatch */
Original file line number Diff line number Diff line change @@ -638,8 +638,6 @@ CheckProcSignal(ProcSignalReason reason)
638
638
void
639
639
procsignal_sigusr1_handler (SIGNAL_ARGS )
640
640
{
641
- int save_errno = errno ;
642
-
643
641
if (CheckProcSignal (PROCSIG_CATCHUP_INTERRUPT ))
644
642
HandleCatchupInterrupt ();
645
643
@@ -683,6 +681,4 @@ procsignal_sigusr1_handler(SIGNAL_ARGS)
683
681
HandleRecoveryConflictInterrupt (PROCSIG_RECOVERY_CONFLICT_BUFFERPIN );
684
682
685
683
SetLatch (MyLatch );
686
-
687
- errno = save_errno ;
688
684
}
Original file line number Diff line number Diff line change @@ -2970,8 +2970,6 @@ quickdie(SIGNAL_ARGS)
2970
2970
void
2971
2971
die (SIGNAL_ARGS )
2972
2972
{
2973
- int save_errno = errno ;
2974
-
2975
2973
/* Don't joggle the elbow of proc_exit */
2976
2974
if (!proc_exit_inprogress )
2977
2975
{
@@ -2993,8 +2991,6 @@ die(SIGNAL_ARGS)
2993
2991
*/
2994
2992
if (DoingCommandRead && whereToSendOutput != DestRemote )
2995
2993
ProcessInterrupts ();
2996
-
2997
- errno = save_errno ;
2998
2994
}
2999
2995
3000
2996
/*
@@ -3004,8 +3000,6 @@ die(SIGNAL_ARGS)
3004
3000
void
3005
3001
StatementCancelHandler (SIGNAL_ARGS )
3006
3002
{
3007
- int save_errno = errno ;
3008
-
3009
3003
/*
3010
3004
* Don't joggle the elbow of proc_exit
3011
3005
*/
@@ -3017,8 +3011,6 @@ StatementCancelHandler(SIGNAL_ARGS)
3017
3011
3018
3012
/* If we're still here, waken anything waiting on the process latch */
3019
3013
SetLatch (MyLatch );
3020
-
3021
- errno = save_errno ;
3022
3014
}
3023
3015
3024
3016
/* signal handler for floating point exception */
Original file line number Diff line number Diff line change @@ -363,8 +363,6 @@ schedule_alarm(TimestampTz now)
363
363
static void
364
364
handle_sig_alarm (SIGNAL_ARGS )
365
365
{
366
- int save_errno = errno ;
367
-
368
366
/*
369
367
* Bump the holdoff counter, to make sure nothing we call will process
370
368
* interrupts directly. No timeout handler should do that, but these
@@ -452,8 +450,6 @@ handle_sig_alarm(SIGNAL_ARGS)
452
450
}
453
451
454
452
RESUME_INTERRUPTS ();
455
-
456
- errno = save_errno ;
457
453
}
458
454
459
455
Original file line number Diff line number Diff line change @@ -152,7 +152,6 @@ ResetCancelConn(void)
152
152
static void
153
153
handle_sigint (SIGNAL_ARGS )
154
154
{
155
- int save_errno = errno ;
156
155
char errbuf [256 ];
157
156
158
157
CancelRequested = true;
@@ -173,8 +172,6 @@ handle_sigint(SIGNAL_ARGS)
173
172
write_stderr (errbuf );
174
173
}
175
174
}
176
-
177
- errno = save_errno ; /* just in case the write changed it */
178
175
}
179
176
180
177
/*
Original file line number Diff line number Diff line change @@ -80,10 +80,14 @@ static volatile pqsigfunc pqsignal_handlers[PG_NSIG];
80
80
* processes do not modify shared memory, which is often detrimental. If the
81
81
* check succeeds, the function originally provided to pqsignal() is called.
82
82
* Otherwise, the default signal handler is installed and then called.
83
+ *
84
+ * This wrapper also handles restoring the value of errno.
83
85
*/
84
86
static void
85
87
wrapper_handler (SIGNAL_ARGS )
86
88
{
89
+ int save_errno = errno ;
90
+
87
91
#ifndef FRONTEND
88
92
89
93
/*
@@ -102,6 +106,8 @@ wrapper_handler(SIGNAL_ARGS)
102
106
#endif
103
107
104
108
(* pqsignal_handlers [postgres_signal_arg ]) (postgres_signal_arg );
109
+
110
+ errno = save_errno ;
105
111
}
106
112
107
113
/*
You can’t perform that action at this time.
0 commit comments