mirror of https://github.com/getdnsapi/getdns.git
Merge pull request #121 from saradickinson/feature/hackathon1
Fix seg fault on timeout
This commit is contained in:
commit
638bc9f7b1
17
src/stub.c
17
src/stub.c
|
@ -467,14 +467,13 @@ tls_cleanup(getdns_upstream *upstream)
|
||||||
NULL, upstream_write_cb, NULL));
|
NULL, upstream_write_cb, NULL));
|
||||||
/* Reset sync event, with full timeout (which isn't correct)*/
|
/* Reset sync event, with full timeout (which isn't correct)*/
|
||||||
getdns_network_req *netreq = upstream->write_queue;
|
getdns_network_req *netreq = upstream->write_queue;
|
||||||
if (netreq && (netreq->event.write_cb || netreq->event.read_cb)) {
|
if (netreq) {
|
||||||
GETDNS_CLEAR_EVENT(netreq->owner->loop, &netreq->event);
|
GETDNS_CLEAR_EVENT(netreq->owner->loop, &netreq->event);
|
||||||
GETDNS_SCHEDULE_EVENT(
|
GETDNS_SCHEDULE_EVENT(
|
||||||
netreq->owner->loop, upstream->fd, netreq->owner->context->timeout,
|
netreq->owner->loop, upstream->fd, netreq->owner->context->timeout,
|
||||||
getdns_eventloop_event_init(
|
getdns_eventloop_event_init(&netreq->event, netreq, NULL,
|
||||||
&netreq->event, netreq,
|
( netreq->owner->loop != netreq->upstream->loop /* Synchronous lookup? */
|
||||||
NULL, netreq_upstream_write_cb,
|
? netreq_upstream_write_cb : NULL), stub_timeout_cb));
|
||||||
stub_timeout_cb));
|
|
||||||
}
|
}
|
||||||
return STUB_TLS_SETUP_ERROR;
|
return STUB_TLS_SETUP_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1011,6 +1010,12 @@ tls_do_handshake(getdns_upstream *upstream)
|
||||||
GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd, TIMEOUT_FOREVER,
|
GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd, TIMEOUT_FOREVER,
|
||||||
getdns_eventloop_event_init(&upstream->event, upstream,
|
getdns_eventloop_event_init(&upstream->event, upstream,
|
||||||
NULL, upstream_write_cb, NULL));
|
NULL, upstream_write_cb, NULL));
|
||||||
|
GETDNS_CLEAR_EVENT(netreq->owner->loop, &netreq->event);
|
||||||
|
GETDNS_SCHEDULE_EVENT(
|
||||||
|
netreq->owner->loop, upstream->fd, netreq->owner->context->timeout,
|
||||||
|
getdns_eventloop_event_init(&netreq->event, netreq, NULL,
|
||||||
|
( netreq->owner->loop != netreq->upstream->loop /* Synchronous lookup? */
|
||||||
|
? netreq_upstream_write_cb : NULL), stub_timeout_cb));
|
||||||
/* Reschedule for synchronous */
|
/* Reschedule for synchronous */
|
||||||
/* TODO[TLS]: Re-instating full context->timeout here is wrong, as time has
|
/* TODO[TLS]: Re-instating full context->timeout here is wrong, as time has
|
||||||
passes since the netreq was originally scheduled, but we only hove one
|
passes since the netreq was originally scheduled, but we only hove one
|
||||||
|
@ -1994,7 +1999,7 @@ _getdns_submit_stub_request(getdns_network_req *netreq)
|
||||||
GETDNS_SCHEDULE_EVENT(
|
GETDNS_SCHEDULE_EVENT(
|
||||||
dnsreq->loop, netreq->upstream->fd, /*dnsreq->context->timeout,*/
|
dnsreq->loop, netreq->upstream->fd, /*dnsreq->context->timeout,*/
|
||||||
(transport == GETDNS_TRANSPORT_TLS ?
|
(transport == GETDNS_TRANSPORT_TLS ?
|
||||||
dnsreq->context->timeout / 2 : dnsreq->context->timeout),
|
dnsreq->context->timeout /2 : dnsreq->context->timeout),
|
||||||
getdns_eventloop_event_init(&netreq->event, netreq, NULL,
|
getdns_eventloop_event_init(&netreq->event, netreq, NULL,
|
||||||
( dnsreq->loop != netreq->upstream->loop /* Synchronous lookup? */
|
( dnsreq->loop != netreq->upstream->loop /* Synchronous lookup? */
|
||||||
? netreq_upstream_write_cb : NULL),
|
? netreq_upstream_write_cb : NULL),
|
||||||
|
|
Loading…
Reference in New Issue