Fixed missed wake-ups and stale responses in legacy and sliding sync long polls. Contributed by @eleboucher.