poll: fix poll_sync() on unconnected sockets

An unconnected socket needs to wait for a connection event; this does not
change sockbuf::sb_cc and so can't be waited on with sbwait().

Detect this and bail out early.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
poll: fix poll_sync() early termination

sbwait() can return with a false positive (say with an ACK only
packet) and so we return with incorrect results.

Fix by looping until we get either some events or a timeout.

Seen in netperf.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>