mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Support asynchronous connect() in Unix networking. Now a port
forwarding to a nonexistent host shouldn't hold up the rest of the program. [originally from svn r2514]
This commit is contained in:
parent
4d86f5979d
commit
f928707849
29
unix/uxnet.c
29
unix/uxnet.c
@ -490,6 +490,11 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
|
|||||||
a.sin_port = htons((short) port);
|
a.sin_port = htons((short) port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
ioctl(s, FIONBIO, &i);
|
||||||
|
}
|
||||||
|
|
||||||
if ((
|
if ((
|
||||||
#ifdef IPV6
|
#ifdef IPV6
|
||||||
connect(s, ((addr->family == AF_INET6) ?
|
connect(s, ((addr->family == AF_INET6) ?
|
||||||
@ -499,13 +504,7 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
|
|||||||
connect(s, (struct sockaddr *) &a, sizeof(a))
|
connect(s, (struct sockaddr *) &a, sizeof(a))
|
||||||
#endif
|
#endif
|
||||||
) < 0) {
|
) < 0) {
|
||||||
/*
|
if ( errno != EINPROGRESS ) {
|
||||||
* FIXME: We are prepared to receive EWOULDBLOCK here,
|
|
||||||
* because we might want the connection to be made
|
|
||||||
* asynchronously; but how do we actually arrange this in
|
|
||||||
* Unix? I forget.
|
|
||||||
*/
|
|
||||||
if ( errno != EWOULDBLOCK ) {
|
|
||||||
ret->error = error_string(errno);
|
ret->error = error_string(errno);
|
||||||
return (Socket) ret;
|
return (Socket) ret;
|
||||||
}
|
}
|
||||||
@ -782,11 +781,6 @@ int select_result(int fd, int event)
|
|||||||
noise_ultralight(event);
|
noise_ultralight(event);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
#ifdef FIXME_NONBLOCKING_CONNECTIONS
|
|
||||||
case FIXME: /* connected */
|
|
||||||
s->connected = s->writable = 1;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case 4: /* exceptional */
|
case 4: /* exceptional */
|
||||||
if (!s->oobinline) {
|
if (!s->oobinline) {
|
||||||
/*
|
/*
|
||||||
@ -883,7 +877,14 @@ int select_result(int fd, int event)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: /* writable */
|
case 2: /* writable */
|
||||||
{
|
if (!s->connected) {
|
||||||
|
/*
|
||||||
|
* select() reports a socket as _writable_ when an
|
||||||
|
* asynchronous connection is completed.
|
||||||
|
*/
|
||||||
|
s->connected = s->writable = 1;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
int bufsize_before, bufsize_after;
|
int bufsize_before, bufsize_after;
|
||||||
s->writable = 1;
|
s->writable = 1;
|
||||||
bufsize_before = s->sending_oob + bufchain_size(&s->output_data);
|
bufsize_before = s->sending_oob + bufchain_size(&s->output_data);
|
||||||
@ -988,6 +989,8 @@ static void sk_tcp_set_frozen(Socket sock, int is_frozen)
|
|||||||
static void set_rwx(Actual_Socket s, int *rwx)
|
static void set_rwx(Actual_Socket s, int *rwx)
|
||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
if (!s->connected)
|
||||||
|
val |= 2; /* write == connect */
|
||||||
if (s->connected && !s->frozen)
|
if (s->connected && !s->frozen)
|
||||||
val |= 1 | 4; /* read, except */
|
val |= 1 | 4; /* read, except */
|
||||||
if (bufchain_size(&s->output_data))
|
if (bufchain_size(&s->output_data))
|
||||||
|
Loading…
Reference in New Issue
Block a user