Thread: pgsql: Move interrupt-handling code into subroutines.

pgsql: Move interrupt-handling code into subroutines.

From
Robert Haas
Date:
Move interrupt-handling code into subroutines.

Some auxiliary processes, as well as the autovacuum launcher,
have interrupt handling code directly in their main loops.
Try to abstract things a little better by moving it into
separate functions.

This doesn't make any functional difference, and leaves
in place relatively large differences among processes in how
interrupts are handled, but hopefully it at least makes it
easier to see the commonalities and differences across
process types.

Patch by me, reviewed by Andres Freund and Daniel Gustafsson.

Discussion: http://postgr.es/m/CA+TgmoZwDk=BguVDVa+qdA6SBKef=PKbaKDQALTC_9qoz1mJqg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5910d6c7e311f0b14e3d3cb9ce3597c01d3a3cde

Modified Files
--------------
src/backend/postmaster/autovacuum.c   | 72 ++++++++++++++++++++++-------------
src/backend/postmaster/bgwriter.c     | 42 ++++++++++++--------
src/backend/postmaster/checkpointer.c | 71 +++++++++++++++++++---------------
src/backend/postmaster/walwriter.c    | 34 ++++++++++-------
4 files changed, 133 insertions(+), 86 deletions(-)


Re: pgsql: Move interrupt-handling code into subroutines.

From
Andrew Gierth
Date:
>>>>> "Robert" == Robert Haas <rhaas@postgresql.org> writes:

 Robert> Move interrupt-handling code into subroutines.

This is eliciting compiler warnings from gcc, which apparently doesn't
count "static void foo();" as being a prototype (quite reasonably, since
it's not).

Needs this fix (in autovacuum.c and checkpointer.c):

-static void AutoVacLauncherShutdown() pg_attribute_noreturn();
+static void AutoVacLauncherShutdown(void) pg_attribute_noreturn();

-static void HandleCheckpointerInterrupts();
+static void HandleCheckpointerInterrupts(void);

-- 
Andrew (irc:RhodiumToad)



Re: pgsql: Move interrupt-handling code into subroutines.

From
Robert Haas
Date:
On Tue, Dec 17, 2019 at 1:43 PM Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
> >>>>> "Robert" == Robert Haas <rhaas@postgresql.org> writes:
>
>  Robert> Move interrupt-handling code into subroutines.
>
> This is eliciting compiler warnings from gcc, which apparently doesn't
> count "static void foo();" as being a prototype (quite reasonably, since
> it's not).
>
> Needs this fix (in autovacuum.c and checkpointer.c):
>
> -static void AutoVacLauncherShutdown() pg_attribute_noreturn();
> +static void AutoVacLauncherShutdown(void) pg_attribute_noreturn();
>
> -static void HandleCheckpointerInterrupts();
> +static void HandleCheckpointerInterrupts(void);

Sorry about that. Fix pushed.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company