mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 15:05:23 +00:00
Always call the TCP dispatch connected callbacks asynchronously
The TCP dispatch connected callbacks could be called synchronously which in turn could destroy xfrin before we return from dns_xfrin_create(). Delay the calling the callback called from tcp_dispatch_connect() by calling it always asynchronously.
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <isc/async.h>
|
||||||
#include <isc/hash.h>
|
#include <isc/hash.h>
|
||||||
#include <isc/hashmap.h>
|
#include <isc/hashmap.h>
|
||||||
#include <isc/loop.h>
|
#include <isc/loop.h>
|
||||||
@@ -1776,6 +1777,16 @@ tcp_startrecv(dns_dispatch_t *disp, dns_dispentry_t *resp) {
|
|||||||
disp->reading = true;
|
disp->reading = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
resp_connected(void *arg) {
|
||||||
|
dns_dispentry_t *resp = arg;
|
||||||
|
dispentry_log(resp, ISC_LOG_DEBUG(90), "connect callback: %s",
|
||||||
|
isc_result_totext(resp->result));
|
||||||
|
|
||||||
|
resp->connected(resp->result, NULL, resp->arg);
|
||||||
|
dns_dispentry_detach(&resp); /* DISPENTRY005 */
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tcp_connected(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
|
tcp_connected(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
|
||||||
dns_dispatch_t *disp = (dns_dispatch_t *)arg;
|
dns_dispatch_t *disp = (dns_dispatch_t *)arg;
|
||||||
@@ -1846,10 +1857,7 @@ tcp_connected(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
|
|||||||
next = ISC_LIST_NEXT(resp, rlink);
|
next = ISC_LIST_NEXT(resp, rlink);
|
||||||
ISC_LIST_UNLINK(resps, resp, rlink);
|
ISC_LIST_UNLINK(resps, resp, rlink);
|
||||||
|
|
||||||
dispentry_log(resp, ISC_LOG_DEBUG(90), "connect callback: %s",
|
resp_connected(resp);
|
||||||
isc_result_totext(resp->result));
|
|
||||||
resp->connected(resp->result, NULL, resp->arg);
|
|
||||||
dns_dispentry_detach(&resp); /* DISPENTRY005 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_dispatch_detach(&disp); /* DISPATCH003 */
|
dns_dispatch_detach(&disp); /* DISPATCH003 */
|
||||||
@@ -1999,10 +2007,9 @@ tcp_dispatch_connect(dns_dispatch_t *disp, dns_dispentry_t *resp) {
|
|||||||
tcp_startrecv(disp, resp);
|
tcp_startrecv(disp, resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We are already connected; call the connected cb */
|
/* Already connected; call the connected cb asynchronously */
|
||||||
dispentry_log(resp, ISC_LOG_DEBUG(90), "connect callback: %s",
|
dns_dispentry_ref(resp); /* DISPENTRY005 */
|
||||||
isc_result_totext(ISC_R_SUCCESS));
|
isc_async_run(resp->loop, resp_connected, resp);
|
||||||
resp->connected(ISC_R_SUCCESS, NULL, resp->arg);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user