[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

possible issue with bsd_poll() on Windows


I am seeing issues using non-blocking sockets on Windows. In particular, if I attempt to connect to either a non-reachable host or a host that doesn't have the specified port open the ssh_connect() call will never fail and will be stuck in a loop returning SSH_AGAIN. This same code behaves perfectly fine running on Linux.

I think I've tracked down the issue to the bsd_poll implementation in poll.c. The documentation for select ( https://docs.microsoft.com/en-us/windows/desktop/api/winsock2/nf-winsock2-select ) notes

	Out-of-band data will only be reported in this way if the option SO_OOBINLINE is FALSE. 
	If a socket is processing a connect call (nonblocking), failure of the connect attempt is indicated 
	in exceptfds (application must then call getsockopt SO_ERROR to determine the error value to 
	describe why the failure occurred). This document does not define which other errors will be included.

In bsd_poll if exceptfds is set it only ORs in POLLPRI | POLLRDBAND. It does not follow the suggestions in the documentation to call getsockopt to get the connection error. I've hacked in a call to getsockopt that checks to see if the error is WSAECONNREFUSED which does then report the connection failure but the error reported later via ssh_get_error is 'Unknown error'. I don't fully understand how bsd_poll is intended to return errors so I don't know the best way to bubble the error up.

On a related note, is reporting this via the email list the best way or should I submit a bug to https://bugs.libssh.org/?

John

Follow-Ups:
Re: possible issue with bsd_poll() on WindowsAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org