]> asedeno.scripts.mit.edu Git - PuTTY.git/commit
Rework handling of asynchronous connect(2) errors on Unix.
authorSimon Tatham <anakin@pobox.com>
Tue, 24 Jan 2017 22:30:44 +0000 (22:30 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 28 Jan 2017 14:03:09 +0000 (14:03 +0000)
commitb73c1c1deb9e0c6080ce27d70191a7242886bea3
tree94179dc0d92423ae203d345904829745ad397513
parent19467455fe7840ab146f47136c88f61c87365e8c
Rework handling of asynchronous connect(2) errors on Unix.

If connect() returns EINPROGRESS, then previously we would detect a
successful connection by the socket becoming selectable for writing,
and spot an unsuccessful one by an error code being returned on the
first attempt to read from it.

This isn't the right way to do it: the right way is to respond to the
initial writability notification by calling getsockopt(SO_ERROR) to
retrieve the error code (if any) from the completed connection
attempt. Doing it the old way had the problem that when the socket
became writable, we could sometimes already have written some of our
outgoing data to it before finding out that the connect attempt failed
- which meant we'd discard that data from the bufchain, and no longer
have it to send through a later successful connection to a different
candidate address.
unix/uxnet.c