Fix race condition in win32 signal handling.
Fix race condition in win32 signal handling.

There was a race condition where the receiving pipe could be closed by the
child thread if the main thread was pre-empted before it got a chance to
create a new one, and the dispatch thread ran to completion during that time.

One symptom of this is that rows in pg_listener could be dropped under
heavy load.

Analysis and original patch by Radu Ilie, with some small
modifications by Magnus Hagander.

Quikling/gpdb,chrishajas/gpdb,zaksoup/gpdb,janebeckman/gpdb,royc1/gpdb,chrishajas/gpdb,royc1/gpdb,ahachete/gpdb,Chibin/gpdb,yuanzhao/gpdb,0x0FFF/gpdb,adam8157/gpdb,0x0FFF/gpdb,greenplum-db/gpdb,kaknikhil/gpdb,Chibin/gpdb,lisakowen/gpdb,royc1/gpdb,rvs/gpdb,rvs/gpdb,rvs/gpdb,0x0FFF/gpdb,edespino/gpdb,50wu/gpdb,Quikling/gpdb,Chibin/gpdb,Chibin/gpdb,edespino/gpdb,50wu/gpdb,ahachete/gpdb,edespino/gpdb,royc1/gpdb,jmcatamney/gpdb,yuanzhao/gpdb,lisakowen/gpdb,yuanzhao/gpdb,zaksoup/gpdb,cjcjameson/gpdb,cjcjameson/gpdb,Chibin/gpdb,xuegang/gpdb,0x0FFF/gpdb,adam8157/gpdb,xinzweb/gpdb,xinzweb/gpdb,0x0FFF/gpdb,janebeckman/gpdb,CraigHarris/gpdb,yuanzhao/gpdb,janebeckman/gpdb,0x0FFF/gpdb,CraigHarris/gpdb,cjcjameson/gpdb,xuegang/gpdb,jmcatamney/gpdb,xinzweb/gpdb,janebeckman/gpdb,lintzc/gpdb,lintzc/gpdb,ahachete/gpdb,kaknikhil/gpdb,rvs/gpdb,CraigHarris/gpdb,kaknikhil/gpdb,ashwinstar/gpdb,janebeckman/gpdb,edespino/gpdb,chrishajas/gpdb,jmcatamney/gpdb,adam8157/gpdb,greenplum-db/gpdb,xinzweb/gpdb,lintzc/gpdb,rvs/gpdb,cjcjameson/gpdb,adam8157/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,cjcjameson/gpdb,adam8157/gpdb,lisakowen/gpdb,kaknikhil/gpdb,50wu/gpdb,0x0FFF/gpdb,edespino/gpdb,ahachete/gpdb,lintzc/gpdb,kaknikhil/gpdb,CraigHarris/gpdb,xuegang/gpdb,CraigHarris/gpdb,yuanzhao/gpdb,royc1/gpdb,ahachete/gpdb,rvs/gpdb,ashwinstar/gpdb,Chibin/gpdb,cjcjameson/gpdb,lisakowen/gpdb,royc1/gpdb,xuegang/gpdb,adam8157/gpdb,Quikling/gpdb,Quikling/gpdb,yuanzhao/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,CraigHarris/gpdb,lintzc/gpdb,kaknikhil/gpdb,kaknikhil/gpdb,rvs/gpdb,CraigHarris/gpdb,lisakowen/gpdb,janebeckman/gpdb,royc1/gpdb,50wu/gpdb,lintzc/gpdb,lintzc/gpdb,chrishajas/gpdb,ashwinstar/gpdb,50wu/gpdb,jmcatamney/gpdb,rvs/gpdb,edespino/gpdb,Quikling/gpdb,xuegang/gpdb,50wu/gpdb,zaksoup/gpdb,zaksoup/gpdb,edespino/gpdb,greenplum-db/gpdb,janebeckman/gpdb,Chibin/gpdb,ashwinstar/gpdb,Quikling/gpdb,zaksoup/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,ahachete/gpdb,xinzweb/gpdb,xinzweb/gpdb,lisakowen/gpdb,xuegang/gpdb,jmcatamney/gpdb,Quikling/gpdb,ahachete/gpdb,CraigHarris/gpdb,xuegang/gpdb,kaknikhil/gpdb,lintzc/gpdb,cjcjameson/gpdb,chrishajas/gpdb,rvs/gpdb,edespino/gpdb,50wu/gpdb,Chibin/gpdb,ahachete/gpdb,yuanzhao/gpdb,chrishajas/gpdb,Quikling/gpdb,rvs/gpdb,xinzweb/gpdb,50wu/gpdb,zaksoup/gpdb,greenplum-db/gpdb,edespino/gpdb,cjcjameson/gpdb,0x0FFF/gpdb,cjcjameson/gpdb,yuanzhao/gpdb,Chibin/gpdb,zaksoup/gpdb,chrishajas/gpdb,janebeckman/gpdb,cjcjameson/gpdb,zaksoup/gpdb,lisakowen/gpdb,CraigHarris/gpdb,adam8157/gpdb,yuanzhao/gpdb,kaknikhil/gpdb,Chibin/gpdb,xinzweb/gpdb,ashwinstar/gpdb,janebeckman/gpdb,lisakowen/gpdb,xuegang/gpdb,janebeckman/gpdb,jmcatamney/gpdb,chrishajas/gpdb,royc1/gpdb,xuegang/gpdb,adam8157/gpdb,jmcatamney/gpdb,kaknikhil/gpdb,yuanzhao/gpdb,lintzc/gpdb,Quikling/gpdb,greenplum-db/gpdb,Quikling/gpdb,edespino/gpdb