Process multiple packets per tick

Before this change we would process at most one gearman packet per tick.
This meant that if we got more than one packet in a single socket read
per tick we would slowly build up a large buffer of un-read packets
(@remainder in the code). This caused problems as we started to run out
of memory and get buffer too large errors.

To solve this problem we loop and process all the packets we can in one
go.
There's also a middle ground, I think, of having the "header length check" as the condition for the while loop and having the "packet length check" the first statement in the while loop.