mirror of https://github.com/getdnsapi/getdns.git
Check destruction of upstreams in correct way
This commit is contained in:
parent
587b320d95
commit
3c80a8a1af
|
@ -526,19 +526,22 @@ priv_getdns_upstreams_dereference(getdns_upstreams *upstreams)
|
||||||
{
|
{
|
||||||
getdns_upstream *upstream;
|
getdns_upstream *upstream;
|
||||||
|
|
||||||
if (upstreams && --upstreams->referenced > 0)
|
if (!upstreams || --upstreams->referenced > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for ( upstream = upstreams->upstreams
|
for ( upstream = upstreams->upstreams
|
||||||
; upstreams->count
|
; upstreams->count
|
||||||
; upstreams->count--, upstream++ ) {
|
; upstreams->count--, upstream++ ) {
|
||||||
|
|
||||||
if ( upstream->event.read_cb
|
if (upstream->loop && ( upstream->event.read_cb
|
||||||
|| upstream->event.write_cb
|
|| upstream->event.write_cb
|
||||||
|| upstream->event.timeout_cb )
|
|| upstream->event.timeout_cb) ) {
|
||||||
|
|
||||||
|
upstream->event.read_cb = NULL;
|
||||||
|
upstream->event.write_cb = NULL;
|
||||||
|
upstream->event.timeout_cb = NULL;
|
||||||
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
|
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
|
||||||
|
}
|
||||||
if (upstream->tls_obj != NULL) {
|
if (upstream->tls_obj != NULL) {
|
||||||
SSL_shutdown(upstream->tls_obj);
|
SSL_shutdown(upstream->tls_obj);
|
||||||
SSL_free(upstream->tls_obj);
|
SSL_free(upstream->tls_obj);
|
||||||
|
@ -550,7 +553,8 @@ priv_getdns_upstreams_dereference(getdns_upstreams *upstreams)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
priv_getdns_upstream_shutdown(getdns_upstream *upstream) {
|
priv_getdns_upstream_shutdown(getdns_upstream *upstream)
|
||||||
|
{
|
||||||
/*There is a race condition with a new request being scheduled
|
/*There is a race condition with a new request being scheduled
|
||||||
while this happens so take ownership of the fd asap*/
|
while this happens so take ownership of the fd asap*/
|
||||||
int fd = upstream->fd;
|
int fd = upstream->fd;
|
||||||
|
|
Loading…
Reference in New Issue