added condition variable again (after some busy waiting, some yielding) to stop server from spinning forever