mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
added shutdown callback to client object;
used it to abort outgoing zone transfers on client shutdown
This commit is contained in:
@@ -208,6 +208,10 @@ client_shutdown(isc_task_t *task, isc_event_t *event) {
|
||||
CTRACE("shutdown");
|
||||
|
||||
client->shuttingdown = ISC_TRUE;
|
||||
|
||||
if (client->shutdown != NULL)
|
||||
(client->shutdown)(client->shutdown_arg);
|
||||
|
||||
maybe_free(client);
|
||||
|
||||
isc_event_free(&event);
|
||||
@@ -850,6 +854,8 @@ client_create(ns_clientmgr_t *manager, ns_clienttype_t type,
|
||||
client->opt = NULL;
|
||||
client->udpsize = 512;
|
||||
client->next = NULL;
|
||||
client->shutdown = NULL;
|
||||
client->shutdown_arg = NULL;
|
||||
dns_name_init(&client->signername, NULL);
|
||||
client->mortal = ISC_FALSE;
|
||||
client->quota = NULL;
|
||||
|
@@ -65,6 +65,8 @@ struct ns_client {
|
||||
dns_rdataset_t * opt;
|
||||
isc_uint16_t udpsize;
|
||||
void (*next)(ns_client_t *, isc_result_t);
|
||||
void (*shutdown)(void *arg);
|
||||
void *shutdown_arg;
|
||||
ns_query_t query;
|
||||
isc_stdtime_t requesttime;
|
||||
isc_stdtime_t now;
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: xfrout.c,v 1.35 2000/01/12 01:17:26 gson Exp $ */
|
||||
/* $Id: xfrout.c,v 1.36 2000/01/12 18:01:11 gson Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -321,7 +321,6 @@ typedef struct ixfr_rrstream {
|
||||
static void ixfr_rrstream_destroy(rrstream_t **sp);
|
||||
static rrstream_methods_t ixfr_rrstream_methods;
|
||||
|
||||
|
||||
/*
|
||||
* Returns: anything dns_journal_open() or dns_journal_iter_init()
|
||||
* may return.
|
||||
@@ -765,6 +764,7 @@ static void xfrout_timeout(isc_task_t *task, isc_event_t *event);
|
||||
static void xfrout_fail(xfrout_ctx_t *xfr, isc_result_t result, char *msg);
|
||||
static void xfrout_maybe_destroy(xfrout_ctx_t *xfr);
|
||||
static void xfrout_ctx_destroy(xfrout_ctx_t **xfrp);
|
||||
static void xfrout_client_shutdown(void *arg);
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
@@ -1104,6 +1104,15 @@ xfrout_ctx_create(isc_mem_t *mctx, ns_client_t *client, unsigned int id,
|
||||
&expires, &idleinterval,
|
||||
xfr->client->task,
|
||||
xfrout_timeout, xfr, &xfr->timer));
|
||||
|
||||
/*
|
||||
* Register a shutdown callback with the client, so that we
|
||||
* can stop the transfer immediately when the client task
|
||||
* gets a shutdown event.
|
||||
*/
|
||||
xfr->client->shutdown = xfrout_client_shutdown;
|
||||
xfr->client->shutdown_arg = xfr;
|
||||
|
||||
*xfrp = xfr;
|
||||
return (DNS_R_SUCCESS);
|
||||
|
||||
@@ -1354,6 +1363,10 @@ xfrout_ctx_destroy(xfrout_ctx_t **xfrp) {
|
||||
xfrout_ctx_t *xfr = *xfrp;
|
||||
|
||||
INSIST(xfr->sends == 0);
|
||||
|
||||
xfr->client->shutdown = NULL;
|
||||
xfr->client->shutdown_arg = NULL;
|
||||
|
||||
if (xfr->timer != NULL)
|
||||
isc_timer_detach(&xfr->timer);
|
||||
if (xfr->stream != NULL)
|
||||
@@ -1439,3 +1452,10 @@ xfrout_maybe_destroy(xfrout_ctx_t *xfr) {
|
||||
xfrout_ctx_destroy(&xfr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xfrout_client_shutdown(void *arg)
|
||||
{
|
||||
xfrout_ctx_t *xfr = (xfrout_ctx_t *) arg;
|
||||
xfrout_fail(xfr, ISC_R_SHUTTINGDOWN, "aborted");
|
||||
}
|
||||
|
Reference in New Issue
Block a user