gthread: improve accepting connections loop

make sure we stop accepting immediately when max connections is achieved.