aboutsummaryrefslogtreecommitdiff
path: root/ares/ares_process.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-05-03 06:11:44 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-05-03 06:11:44 +0000
commitdd06c60ada039faafd937a136e3dc7ff9c41159a (patch)
tree5e5337faa1571a343b4c643da651ca817afc7802 /ares/ares_process.c
parent6ca627ae742816cfca67d7e2ad3b59c269e5651d (diff)
Nick Mathewson added the ARES_OPT_SOCK_STATE_CB option that when set makes
c-ares call a callback on socket state changes. A better way than the ares_getsock() to get full control over the socket state.
Diffstat (limited to 'ares/ares_process.c')
-rw-r--r--ares/ares_process.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/ares/ares_process.c b/ares/ares_process.c
index 456d95218..f38e591f2 100644
--- a/ares/ares_process.c
+++ b/ares/ares_process.c
@@ -149,7 +149,10 @@ static void write_tcp_data(ares_channel channel, fd_set *write_fds, time_t now)
wcount -= sendreq->len;
server->qhead = sendreq->next;
if (server->qhead == NULL)
- server->qtail = NULL;
+ {
+ SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 0);
+ server->qtail = NULL;
+ }
free(sendreq);
}
else
@@ -179,7 +182,10 @@ static void write_tcp_data(ares_channel channel, fd_set *write_fds, time_t now)
{
server->qhead = sendreq->next;
if (server->qhead == NULL)
- server->qtail = NULL;
+ {
+ SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 0);
+ server->qtail = NULL;
+ }
free(sendreq);
}
else
@@ -380,7 +386,7 @@ static void handle_error(ares_channel channel, int whichserver, time_t now)
struct query *query, *next;
/* Reset communications with this server. */
- ares__close_sockets(&channel->servers[whichserver]);
+ ares__close_sockets(channel, &channel->servers[whichserver]);
/* Tell all queries talking to this server to move on and not try
* this server again.
@@ -452,7 +458,10 @@ void ares__send_query(ares_channel channel, struct query *query, time_t now)
if (server->qtail)
server->qtail->next = sendreq;
else
- server->qhead = sendreq;
+ {
+ SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 1);
+ server->qhead = sendreq;
+ }
server->qtail = sendreq;
query->timeout = 0;
}
@@ -575,6 +584,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
}
}
+ SOCK_STATE_CALLBACK(channel, s, 1, 0);
server->tcp_buffer_pos = 0;
server->tcp_socket = s;
return 0;
@@ -604,6 +614,8 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
return -1;
}
+ SOCK_STATE_CALLBACK(channel, s, 1, 0);
+
server->udp_socket = s;
return 0;
}
@@ -714,7 +726,7 @@ static struct query *end_query (ares_channel channel, struct query *query, int s
if (!channel->queries && !(channel->flags & ARES_FLAG_STAYOPEN))
{
for (i = 0; i < channel->nservers; i++)
- ares__close_sockets(&channel->servers[i]);
+ ares__close_sockets(channel, &channel->servers[i]);
}
return (next);
}