return values of backend sub-main functions - Mailing list pgsql-hackers

From Peter Eisentraut
Subject return values of backend sub-main functions
Date
Msg-id 1325971881.14090.8.camel@vanquo.pezone.net
Whole thread Raw
Responses Re: return values of backend sub-main functions
List pgsql-hackers
There is a bit of confusion around the return values and return
protocols of the sub-main functions in the backend (PostgresMain etc.).
Some functions are declared to return int but never return.  It would be
useful to make this consistent by either making them return void or
making some use of the return value.

PostgresMain() is declared to return int but never returns at all, so
why not make it return void?  main() in turn reads the exit code and
passes it to exit().  Similarly, PostmasterMain() never returns, but is
declared to return int.

BackendRun() is declared to return int, and that return value is
actually obtained from the return value of PostgresMain() (see above),
and the return value of BackendRun() is passed to proc_exit().  That
appears to be elaborate nonsense, because the only way to get out of
PostgresMain() is through calling proc_exit in the first place.

PostgresMain() calls proc_exit(WalSenderMain()), but WalSenderMain ends
by calling WalSndLoop which in turn ends by calling proc_exit.

By contrast, AuxiliaryProcessMain() and all the sub-Main() functions
called from there are declared to return void.

I suggest that we change PostgresMain(), PostmasterMain(), BackendRun(),
WalSenderMain(), and WalSndLoop() to return void as well.




pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: random_page_cost vs seq_page_cost
Next
From: Tom Lane
Date:
Subject: Re: return values of backend sub-main functions