Charles Hardin patch:

- handles the EINPROGRESS for UDP connects
- uses closesocket instead of close on some paths that were noticed
pull/1/head
Yang Tse 16 years ago
parent e1b2f2eff4
commit 64c82d0853
  1. 3
      CHANGES
  2. 17
      ares_process.c

@ -1,5 +1,8 @@
Changelog for the c-ares project Changelog for the c-ares project
* Oct 21 2008 (Yang Tse)
Charles Hardin added handling of EINPROGRESS for UDP connects.
* Oct 18 2008 (Daniel Stenberg) * Oct 18 2008 (Daniel Stenberg)
Charles Hardin made adig support a regular numerical dotted IP address for the Charles Hardin made adig support a regular numerical dotted IP address for the
-s option as well. -s option as well.

@ -906,7 +906,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
/* Configure it. */ /* Configure it. */
if (configure_socket(s, channel) < 0) if (configure_socket(s, channel) < 0)
{ {
close(s); closesocket(s);
return -1; return -1;
} }
@ -920,7 +920,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY,
(void *)&opt, sizeof(opt)) == -1) (void *)&opt, sizeof(opt)) == -1)
{ {
close(s); closesocket(s);
return -1; return -1;
} }
@ -929,10 +929,12 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
sockin.sin_family = AF_INET; sockin.sin_family = AF_INET;
sockin.sin_addr = server->addr; sockin.sin_addr = server->addr;
sockin.sin_port = (unsigned short)(channel->tcp_port & 0xffff); sockin.sin_port = (unsigned short)(channel->tcp_port & 0xffff);
if (connect(s, (struct sockaddr *) &sockin, sizeof(sockin)) == -1) { if (connect(s, (struct sockaddr *) &sockin, sizeof(sockin)) == -1)
{
int err = SOCKERRNO; int err = SOCKERRNO;
if (err != EINPROGRESS && err != EWOULDBLOCK) { if (err != EINPROGRESS && err != EWOULDBLOCK)
{
closesocket(s); closesocket(s);
return -1; return -1;
} }
@ -958,7 +960,7 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
/* Set the socket non-blocking. */ /* Set the socket non-blocking. */
if (configure_socket(s, channel) < 0) if (configure_socket(s, channel) < 0)
{ {
close(s); closesocket(s);
return -1; return -1;
} }
@ -968,10 +970,15 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
sockin.sin_addr = server->addr; sockin.sin_addr = server->addr;
sockin.sin_port = (unsigned short)(channel->udp_port & 0xffff); sockin.sin_port = (unsigned short)(channel->udp_port & 0xffff);
if (connect(s, (struct sockaddr *) &sockin, sizeof(sockin)) == -1) if (connect(s, (struct sockaddr *) &sockin, sizeof(sockin)) == -1)
{
int err = SOCKERRNO;
if (err != EINPROGRESS && err != EWOULDBLOCK)
{ {
closesocket(s); closesocket(s);
return -1; return -1;
} }
}
SOCK_STATE_CALLBACK(channel, s, 1, 0); SOCK_STATE_CALLBACK(channel, s, 1, 0);

Loading…
Cancel
Save