Fix removal of dead sockets from the stash

We were modifying the stash array while iterating over it, causing
sockets that were still connected to miss messages.
test for stash removal fix
Merge pull request #1 from kenichi/srf

test for stash removal fix
Merge pull request #11 from chewi/stash_removal_fix

Fix removal of dead sockets from the stash