Handle EINPROGRESS properly.

Set IP_DONTROUTE sockopt only if sk->ttl == 1.
This commit is contained in:
Martin Mares 2000-03-20 21:49:21 +00:00
parent 267a2c0ebd
commit 1cf716f075

View file

@ -451,13 +451,10 @@ sk_setup(sock *s)
#else #else
if ((s->tos >= 0) && setsockopt(fd, SOL_IP, IP_TOS, &s->tos, sizeof(s->tos)) < 0) if ((s->tos >= 0) && setsockopt(fd, SOL_IP, IP_TOS, &s->tos, sizeof(s->tos)) < 0)
WARN("IP_TOS"); WARN("IP_TOS");
if (s->ttl >= 0) if (s->ttl >= 0 && setsockopt(fd, SOL_IP, IP_TTL, &s->ttl, sizeof(s->ttl)) < 0)
{
if (setsockopt(fd, SOL_IP, IP_TTL, &s->ttl, sizeof(s->ttl)) < 0)
ERR("IP_TTL"); ERR("IP_TTL");
if (setsockopt(fd, SOL_SOCKET, SO_DONTROUTE, &one, sizeof(one)) < 0) if (s->ttl == 1 && setsockopt(fd, SOL_SOCKET, SO_DONTROUTE, &one, sizeof(one)) < 0)
ERR("SO_DONTROUTE"); ERR("SO_DONTROUTE");
}
#endif #endif
/* FIXME: Set send/receive buffers? */ /* FIXME: Set send/receive buffers? */
/* FIXME: Set keepalive for TCP connections? */ /* FIXME: Set keepalive for TCP connections? */
@ -618,7 +615,7 @@ sk_open(sock *s)
case SK_TCP_ACTIVE: case SK_TCP_ACTIVE:
if (connect(fd, (struct sockaddr *) &sa, sizeof(sa)) >= 0) if (connect(fd, (struct sockaddr *) &sa, sizeof(sa)) >= 0)
sk_tcp_connected(s); sk_tcp_connected(s);
else if (errno != EINTR && errno != EAGAIN) else if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS)
ERR("connect"); ERR("connect");
break; break;
case SK_TCP_PASSIVE: case SK_TCP_PASSIVE:
@ -776,7 +773,7 @@ sk_read(sock *s)
fill_in_sockaddr(&sa, s->daddr, s->dport); fill_in_sockaddr(&sa, s->daddr, s->dport);
if (connect(s->fd, (struct sockaddr *) &sa, sizeof(sa)) >= 0) if (connect(s->fd, (struct sockaddr *) &sa, sizeof(sa)) >= 0)
sk_tcp_connected(s); sk_tcp_connected(s);
else if (errno != EINTR && errno != EAGAIN) else if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS)
{ {
log(L_ERR "connect: %m"); log(L_ERR "connect: %m");
s->err_hook(s, errno); s->err_hook(s, errno);