Don't call sqs_length in pop, but also don't keep trying to fill the out_buffer from an empty queue. Give up after out_buffer.max attempts.