Fix major issue with threaded worker keepalive

The keepalive queue management is fixed to not pop extra connections
incorrectly.

Close #816
Merge pull request #817 from benoitc/816-gthread-keepalive-pop

Fix major issue with threaded worker keepalive