Server loop does not call dispatch only when running in pthread