Fix races in unix signal dispatch
Fix races in unix signal dispatch

Fix some races introduced in be2c7b83c4a9c9d3aa76b1499c27ab19e0f4e470
while keeping the property that multiple handlers for the same unix
signal all get dispatched.

Also fix the behaviour of the source checking for pending signals when
it's created.  No matter what we do here (clear the pending flag or not)
there is something that can go wrong.

If we clear the flag, we may prevent other sources from being
dispatched.  If we don't clear it, we may end up dispatching the same
source twice (if we manage to dispatch it from its own thread before the
GLib worker has a chance to run).

Instead, run the full dispatch procedure when a new source is added.  It
actually doesn't matter what thread this runs in since the lock is held.

https://bugzilla.gnome.org/show_bug.cgi?id=711090

MathieuDuponchelle/glib,mzabaluev/glib,tchakabam/glib,ieei/glib,mzabaluev/glib,cention-sany/glib,Distrotech/glib,gale320/glib,lukasz-skalski/glib,tchakabam/glib,cention-sany/glib,tamaskenez/glib,johne53/MB3Glib,tamaskenez/glib,johne53/MB3Glib,krichter722/glib,krichter722/glib,krichter722/glib,cention-sany/glib,endlessm/glib,tchakabam/glib,johne53/MB3Glib,MathieuDuponchelle/glib,cention-sany/glib,endlessm/glib,gale320/glib,Distrotech/glib,Distrotech/glib,tamaskenez/glib,MathieuDuponchelle/glib,endlessm/glib,krichter722/glib,lukasz-skalski/glib,mzabaluev/glib,johne53/MB3Glib,tamaskenez/glib,ieei/glib,mzabaluev/glib,johne53/MB3Glib,gale320/glib,lukasz-skalski/glib,ieei/glib,krichter722/glib,MathieuDuponchelle/glib,cention-sany/glib,mzabaluev/glib,lukasz-skalski/glib,ieei/glib,ieei/glib,MathieuDuponchelle/glib,tamaskenez/glib,tchakabam/glib,gale320/glib,endlessm/glib,Distrotech/glib,lukasz-skalski/glib,Distrotech/glib,endlessm/glib,johne53/MB3Glib,gale320/glib,tchakabam/glib