w->ssl_upstream = sq->ssl_upstream;
w->tls_auth_name = sq->tls_auth_name;
#ifndef S_SPLINT_S
- tv.tv_sec = timeout;
- tv.tv_usec = 0;
+ tv.tv_sec = timeout/1000;
+ tv.tv_usec = (timeout%1000)*1000;
#endif
comm_timer_set(w->timer, &tv);
if(pend) {
}
if(sq->tcp_upstream || sq->ssl_upstream) {
struct timeval now = *sq->outnet->now_tv;
- if(now.tv_sec > sq->last_sent_time.tv_sec ||
+ if(error==NETEVENT_TIMEOUT) {
+ if(!infra_rtt_update(sq->outnet->infra, &sq->addr,
+ sq->addrlen, sq->zone, sq->zonelen, sq->qtype,
+ -1, sq->last_rtt, (time_t)now.tv_sec))
+ log_err("out of memory in TCP exponential backoff.");
+ } else if(now.tv_sec > sq->last_sent_time.tv_sec ||
(now.tv_sec == sq->last_sent_time.tv_sec &&
now.tv_usec > sq->last_sent_time.tv_usec)) {
/* convert from microseconds to milliseconds */
log_assert(roundtime >= 0);
/* only store if less then AUTH_TIMEOUT seconds, it could be
* huge due to system-hibernated and we woke up */
- if(roundtime < TCP_AUTH_QUERY_TIMEOUT*1000) {
+ if(roundtime < 60000) {
if(!infra_rtt_update(sq->outnet->infra, &sq->addr,
sq->addrlen, sq->zone, sq->zonelen, sq->qtype,
roundtime, sq->last_rtt, (time_t)now.tv_sec))
static int
serviced_tcp_send(struct serviced_query* sq, sldns_buffer* buff)
{
- int vs, rtt;
+ int vs, rtt, timeout;
uint8_t edns_lame_known;
if(!infra_host(sq->outnet->infra, &sq->addr, sq->addrlen, sq->zone,
sq->zonelen, *sq->outnet->now_secs, &vs, &edns_lame_known,
&rtt))
return 0;
+ sq->last_rtt = rtt;
if(vs != -1)
sq->status = serviced_query_TCP_EDNS;
else sq->status = serviced_query_TCP;
serviced_encode(sq, buff, sq->status == serviced_query_TCP_EDNS);
sq->last_sent_time = *sq->outnet->now_tv;
- sq->pending = pending_tcp_query(sq, buff, TCP_AUTH_QUERY_TIMEOUT,
+ if(sq->tcp_upstream || sq->ssl_upstream) {
+ timeout = rtt;
+ if(rtt >= 376 && rtt < TCP_AUTH_QUERY_TIMEOUT)
+ timeout = TCP_AUTH_QUERY_TIMEOUT;
+ } else {
+ timeout = TCP_AUTH_QUERY_TIMEOUT;
+ }
+ sq->pending = pending_tcp_query(sq, buff, timeout,
serviced_tcp_callback, sq);
return sq->pending != NULL;
}
int retry;
/** time last UDP was sent */
struct timeval last_sent_time;
- /** rtt of last (UDP) message */
+ /** rtt of last message */
int last_rtt;
/** do we know edns probe status already, for UDP_EDNS queries */
int edns_lame_known;
* checks id.
* @param sq: serviced query.
* @param packet: wireformat query to send to destination. copied from.
- * @param timeout: in seconds from now.
+ * @param timeout: in milliseconds from now.
* Timer starts running now. Timer may expire if all buffers are used,
* without any query been sent to the server yet.
* @param callback: function to call on error, timeout or reply.
pend->addrlen = sq->addrlen;
pend->callback = callback;
pend->cb_arg = callback_arg;
- pend->timeout = timeout;
+ pend->timeout = timeout/1000;
pend->transport = transport_tcp;
pend->pkt = NULL;
pend->zone = NULL;
log_assert(pend->zone);
pend->callback = callback;
pend->cb_arg = callback_arg;
- pend->timeout = UDP_AUTH_QUERY_TIMEOUT;
+ pend->timeout = UDP_AUTH_QUERY_TIMEOUT/1000;
pend->transport = transport_udp; /* pretend UDP */
pend->pkt = NULL;
pend->runtime = runtime;
}
pend->callback = fc->cb;
pend->cb_arg = fc->cb_arg;
- pend->timeout = UDP_AUTH_QUERY_TIMEOUT;
+ pend->timeout = UDP_AUTH_QUERY_TIMEOUT/1000;
pend->transport = transport_udp;
pend->pkt = NULL;
pend->runtime = runtime;
/** set RCODE bits in uint16 flags */
#define FLAGS_SET_RCODE(f, r) (f = (((f) & 0xfff0) | (r)))
-/** timeout in seconds for UDP queries to auth servers. */
-#define UDP_AUTH_QUERY_TIMEOUT 4
-/** timeout in seconds for TCP queries to auth servers. */
-#define TCP_AUTH_QUERY_TIMEOUT 30
+/** timeout in milliseconds for UDP queries to auth servers. */
+#define UDP_AUTH_QUERY_TIMEOUT 3000
+/** timeout in milliseconds for TCP queries to auth servers. */
+#define TCP_AUTH_QUERY_TIMEOUT 3000
/** Advertised version of EDNS capabilities */
#define EDNS_ADVERTISED_VERSION 0
/** Advertised size of EDNS capabilities */