* fhandler.h (enum conn_state): Add connect_failed state.

* fhandler_socket.cc (fhandler_socket::connect): Set connect_state to
	connect_failed when connect failed.
	* poll.cc (poll): Change errno to EINVAL if allocating memory fails,
	according to SUSv3. Add socket descriptors always to except_fds. Test
	for failed connect and set revents flags appropriately.
	* select.cc (set_bits): Set connect_state to connect_failed when
	select indicates failed nonblocking connect.
	(fhandler_dev_null::select_except): Set except_ready to false so that
	/dev/null is not always in except state.
	(peek_socket): Fix bogus conditional.
	(fhandler_socket::select_write): Treat all connect_states except
	unconnected equivalent to return consistent results.
	(fhandler_windows::select_except): Set except_ready to false so that
	/dev/windows is not always in except state.
This commit is contained in:
Corinna Vinschen
2005-04-18 18:56:52 +00:00
parent 2180b9627d
commit 04843bf4a0
5 changed files with 50 additions and 17 deletions

View File

@ -706,7 +706,7 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
err = WSAGetLastError ();
/* Special handling for connect to return the correct error code
when called on a non-blocking socket. */
if (is_nonblocking () || connect_state () == connect_pending)
if (is_nonblocking ())
{
if (err == WSAEWOULDBLOCK || err == WSAEALREADY)
in_progress = true;
@ -736,6 +736,8 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
if (err == WSAEINPROGRESS || err == WSAEALREADY)
connect_state (connect_pending);
else if (err)
connect_state (connect_failed);
else
connect_state (connected);