Revise postmaster startup/shutdown logic to eliminate the problem that a constant flow of new connection requests could prevent the postmaster from completing a shutdown or crash restart.  This is done by labeling child processes that are "dead ends", that is, we know that they were launched only to tell a client that it can't connect.  These processes are managed separately so that they don't confuse us into thinking that we can't advance to the next stage of a shutdown or restart sequence, until the very end where we must wait for them to drain out so we can delete the shmem segment. Per discussion of a misbehavior reported by Keaton Adams.
Revise postmaster startup/shutdown logic to eliminate the problem that a
constant flow of new connection requests could prevent the postmaster from
completing a shutdown or crash restart.  This is done by labeling child
processes that are "dead ends", that is, we know that they were launched only
to tell a client that it can't connect.  These processes are managed
separately so that they don't confuse us into thinking that we can't advance
to the next stage of a shutdown or restart sequence, until the very end
where we must wait for them to drain out so we can delete the shmem segment.
Per discussion of a misbehavior reported by Keaton Adams.

Since this code was baroque already, and my first attempt at fixing the
problem made it entirely impenetrable, I took the opportunity to rewrite it
in a state-machine style.  That eliminates some duplicated code sections and
hopefully makes everything a bit clearer.

jmcatamney/gpdb,50wu/gpdb,pavanvd/postgres-xl,oberstet/postgres-xl,Quikling/gpdb,yuanzhao/gpdb,lisakowen/gpdb,kaknikhil/gpdb,pavanvd/postgres-xl,techdragon/Postgres-XL,jmcatamney/gpdb,chrishajas/gpdb,Quikling/gpdb,lintzc/gpdb,royc1/gpdb,oberstet/postgres-xl,xinzweb/gpdb,techdragon/Postgres-XL,0x0FFF/gpdb,xuegang/gpdb,kaknikhil/gpdb,Postgres-XL/Postgres-XL,Postgres-XL/Postgres-XL,adam8157/gpdb,Postgres-XL/Postgres-XL,CraigHarris/gpdb,jmcatamney/gpdb,snaga/postgres-xl,adam8157/gpdb,cjcjameson/gpdb,xinzweb/gpdb,adam8157/gpdb,techdragon/Postgres-XL,postmind-net/postgres-xl,cjcjameson/gpdb,zeroae/postgres-xl,xinzweb/gpdb,ovr/postgres-xl,postmind-net/postgres-xl,janebeckman/gpdb,adam8157/gpdb,CraigHarris/gpdb,adam8157/gpdb,janebeckman/gpdb,yazun/postgres-xl,xuegang/gpdb,yazun/postgres-xl,0x0FFF/gpdb,cjcjameson/gpdb,greenplum-db/gpdb,janebeckman/gpdb,greenplum-db/gpdb,oberstet/postgres-xl,postmind-net/postgres-xl,xinzweb/gpdb,arcivanov/postgres-xl,zeroae/postgres-xl,Quikling/gpdb,arcivanov/postgres-xl,jmcatamney/gpdb,Chibin/gpdb,rvs/gpdb,chrishajas/gpdb,jmcatamney/gpdb,adam8157/gpdb,royc1/gpdb,royc1/gpdb,Quikling/gpdb,tpostgres-projects/tPostgres,Chibin/gpdb,greenplum-db/gpdb,yazun/postgres-xl,yuanzhao/gpdb,kaknikhil/gpdb,janebeckman/gpdb,cjcjameson/gpdb,janebeckman/gpdb,kmjungersen/PostgresXL,ashwinstar/gpdb,edespino/gpdb,ovr/postgres-xl,kaknikhil/gpdb,kmjungersen/PostgresXL,kmjungersen/PostgresXL,yuanzhao/gpdb,yuanzhao/gpdb,techdragon/Postgres-XL,rvs/gpdb,oberstet/postgres-xl,jmcatamney/gpdb,CraigHarris/gpdb,chrishajas/gpdb,jmcatamney/gpdb,CraigHarris/gpdb,lisakowen/gpdb,royc1/gpdb,zaksoup/gpdb,lintzc/gpdb,royc1/gpdb,ovr/postgres-xl,royc1/gpdb,ahachete/gpdb,Chibin/gpdb,50wu/gpdb,cjcjameson/gpdb,adam8157/gpdb,edespino/gpdb,kaknikhil/gpdb,arcivanov/postgres-xl,0x0FFF/gpdb,snaga/postgres-xl,50wu/gpdb,xuegang/gpdb,zeroae/postgres-xl,rvs/gpdb,xuegang/gpdb,Quikling/gpdb,0x0FFF/gpdb,kmjungersen/PostgresXL,zaksoup/gpdb,greenplum-db/gpdb,cjcjameson/gpdb,0x0FFF/gpdb,postmind-net/postgres-xl,lisakowen/gpdb,cjcjameson/gpdb,xuegang/gpdb,CraigHarris/gpdb,lisakowen/gpdb,xuegang/gpdb,50wu/gpdb,lisakowen/gpdb,tpostgres-projects/tPostgres,ahachete/gpdb,kaknikhil/gpdb,lintzc/gpdb,zaksoup/gpdb,rvs/gpdb,0x0FFF/gpdb,edespino/gpdb,yuanzhao/gpdb,ahachete/gpdb,lintzc/gpdb,50wu/gpdb,rvs/gpdb,lintzc/gpdb,zaksoup/gpdb,zaksoup/gpdb,greenplum-db/gpdb,Postgres-XL/Postgres-XL,lintzc/gpdb,50wu/gpdb,lintzc/gpdb,Quikling/gpdb,janebeckman/gpdb,ahachete/gpdb,Quikling/gpdb,ashwinstar/gpdb,Chibin/gpdb,kaknikhil/gpdb,ovr/postgres-xl,postmind-net/postgres-xl,jmcatamney/gpdb,snaga/postgres-xl,cjcjameson/gpdb,yuanzhao/gpdb,yuanzhao/gpdb,Chibin/gpdb,xinzweb/gpdb,tpostgres-projects/tPostgres,Chibin/gpdb,lintzc/gpdb,zaksoup/gpdb,xuegang/gpdb,zeroae/postgres-xl,ahachete/gpdb,rvs/gpdb,snaga/postgres-xl,Chibin/gpdb,lisakowen/gpdb,zaksoup/gpdb,ovr/postgres-xl,yuanzhao/gpdb,yuanzhao/gpdb,adam8157/gpdb,chrishajas/gpdb,ashwinstar/gpdb,kaknikhil/gpdb,chrishajas/gpdb,cjcjameson/gpdb,ashwinstar/gpdb,pavanvd/postgres-xl,Chibin/gpdb,xuegang/gpdb,yazun/postgres-xl,50wu/gpdb,oberstet/postgres-xl,xinzweb/gpdb,rvs/gpdb,Quikling/gpdb,tpostgres-projects/tPostgres,ahachete/gpdb,Quikling/gpdb,janebeckman/gpdb,snaga/postgres-xl,CraigHarris/gpdb,edespino/gpdb,royc1/gpdb,greenplum-db/gpdb,xinzweb/gpdb,cjcjameson/gpdb,rvs/gpdb,50wu/gpdb,chrishajas/gpdb,Postgres-XL/Postgres-XL,edespino/gpdb,edespino/gpdb,lisakowen/gpdb,kaknikhil/gpdb,zaksoup/gpdb,edespino/gpdb,royc1/gpdb,zeroae/postgres-xl,rvs/gpdb,tpostgres-projects/tPostgres,Chibin/gpdb,0x0FFF/gpdb,ashwinstar/gpdb,0x0FFF/gpdb,yuanzhao/gpdb,Chibin/gpdb,rvs/gpdb,ashwinstar/gpdb,pavanvd/postgres-xl,ashwinstar/gpdb,xuegang/gpdb,CraigHarris/gpdb,janebeckman/gpdb,kaknikhil/gpdb,ahachete/gpdb,janebeckman/gpdb,janebeckman/gpdb,edespino/gpdb,yazun/postgres-xl,xinzweb/gpdb,lintzc/gpdb,edespino/gpdb,greenplum-db/gpdb,Quikling/gpdb,kmjungersen/PostgresXL,arcivanov/postgres-xl,arcivanov/postgres-xl,chrishajas/gpdb,ahachete/gpdb,CraigHarris/gpdb,CraigHarris/gpdb,ashwinstar/gpdb,lisakowen/gpdb,pavanvd/postgres-xl,arcivanov/postgres-xl,greenplum-db/gpdb,chrishajas/gpdb,techdragon/Postgres-XL,edespino/gpdb