Better lock around event listeners
Better lock around event listeners

This should avoid the case where we attempt to read a now deleted
listener and also fix a race condition on listener deletion.

Signed-off-by: Stéphane Graber <089afc6d81f66f1168a9849e15660feae286e024@ubuntu.com>

lxc/lxd,techtonik/lxd,lxc/lxd,georghopp/lxd,georghopp/lxd,Skarlso/lxd,stgraber/lxd,erikmack/lxd,georghopp/lxd,ollie314/lxd,techtonik/lxd,lxc/lxd,Skarlso/lxd,hallyn/lxd,jsavikko/lxd,atxwebs/lxd,lxc/lxd,stgraber/lxd,lxc/lxd,chrisglass/lxd,pcdummy/lxd,mjeanson/lxd,yura-pakhuchiy/lxd,stgraber/lxd,stgraber/lxd,yura-pakhuchiy/lxd,akshaykarle/lxd,jsavikko/lxd,hallyn/lxd,stgraber/lxd,techtonik/lxd,hallyn/lxd,hallyn/lxd,hallyn/lxd,yura-pakhuchiy/lxd,mjeanson/lxd,stgraber/lxd,atxwebs/lxd,chrisglass/lxd,atxwebs/lxd,erikmack/lxd,lxc/lxd,akshaykarle/lxd,akshaykarle/lxd,atxwebs/lxd,chrisglass/lxd,ollie314/lxd,pcdummy/lxd,Skarlso/lxd,ollie314/lxd,stgraber/lxd,hallyn/lxd,erikmack/lxd,mjeanson/lxd,Skarlso/lxd,lxc/lxd,jsavikko/lxd,pcdummy/lxd