mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
conforming changes for task API simplification
This commit is contained in:
@@ -120,13 +120,6 @@ ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
|
||||
isc_result_totext(result));
|
||||
goto task_create_failure;
|
||||
}
|
||||
result = isc_task_allowdone(ifp->task, ISC_FALSE);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_task_allowdone() failed: %s",
|
||||
isc_result_totext(result));
|
||||
goto task_create_failure;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open a UDP socket.
|
||||
|
@@ -59,7 +59,6 @@ t1_shutdown(isc_task_t *task, isc_event_t *event) {
|
||||
t_info *info = event->arg;
|
||||
|
||||
printf("task %s (%p) t1_shutdown\n", info->name, task);
|
||||
isc_task_allowdone(info->task, ISC_TRUE);
|
||||
isc_task_detach(&info->task);
|
||||
isc_event_free(&event);
|
||||
}
|
||||
@@ -115,7 +114,6 @@ tick(isc_task_t *task, isc_event_t *event)
|
||||
RUNTIME_CHECK(isc_app_shutdown() == ISC_R_SUCCESS);
|
||||
} else if (info->ticks >= 15 && info->exiting) {
|
||||
isc_timer_detach(&info->timer);
|
||||
isc_task_allowdone(info->task, ISC_TRUE);
|
||||
isc_task_detach(&info->task);
|
||||
nevent = isc_event_allocate(info->mctx, info,
|
||||
T2_SHUTDOWNDONE,
|
||||
@@ -200,8 +198,6 @@ main(int argc, char *argv[]) {
|
||||
t2 = new_task(mctx2, NULL);
|
||||
isc_task_attach(t2->task, &t1->peer);
|
||||
isc_task_attach(t1->task, &t2->peer);
|
||||
isc_task_allowdone(t1->task, ISC_FALSE);
|
||||
isc_task_allowdone(t2->task, ISC_FALSE);
|
||||
|
||||
/*
|
||||
* Test run-triggered shutdown.
|
||||
@@ -221,7 +217,6 @@ main(int argc, char *argv[]) {
|
||||
*/
|
||||
RUNTIME_CHECK(isc_task_create(task_manager, mctx, 0, &task) ==
|
||||
ISC_R_SUCCESS);
|
||||
isc_task_allowdone(task, ISC_FALSE);
|
||||
isc_task_detach(&task);
|
||||
|
||||
RUNTIME_CHECK(isc_app_run() == ISC_R_SUCCESS);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -266,34 +266,6 @@ t_timers_x(isc_timertype_t timertype, isc_time_t *expires,
|
||||
return;
|
||||
}
|
||||
|
||||
isc_result = isc_task_allowdone(task, ISC_TRUE);
|
||||
if (isc_result != ISC_R_SUCCESS) {
|
||||
t_info("isc_task_allowdone failed %s\n",
|
||||
isc_result_totext(isc_result));
|
||||
isc_timermgr_destroy(&timermgr);
|
||||
isc_task_destroy(&task);
|
||||
isc_taskmgr_destroy(&tmgr);
|
||||
isc_mutex_destroy(&Tx_mx);
|
||||
isc_condition_destroy(&Tx_cv);
|
||||
isc_mem_destroy(&mctx);
|
||||
++Tx_nprobs;
|
||||
return;
|
||||
}
|
||||
|
||||
isc_result = isc_task_allowsend(task, ISC_TRUE);
|
||||
if (isc_result != ISC_R_SUCCESS) {
|
||||
t_info("isc_task_allowsend failed %s\n",
|
||||
isc_result_totext(isc_result));
|
||||
isc_timermgr_destroy(&timermgr);
|
||||
isc_task_destroy(&task);
|
||||
isc_taskmgr_destroy(&tmgr);
|
||||
isc_mutex_destroy(&Tx_mx);
|
||||
isc_condition_destroy(&Tx_cv);
|
||||
isc_mem_destroy(&mctx);
|
||||
++Tx_nprobs;
|
||||
return;
|
||||
}
|
||||
|
||||
isc_result = isc_time_now(&Tx_lasttime);
|
||||
if (isc_result != ISC_R_SUCCESS) {
|
||||
isc_timermgr_destroy(&timermgr);
|
||||
@@ -921,19 +893,7 @@ t_timers5() {
|
||||
}
|
||||
|
||||
event = isc_event_allocate(mctx, (void *) 1 , (isc_eventtype_t) 1, t5_start_event, NULL, sizeof(*event));
|
||||
isc_result = isc_task_send(T5_task1, &event);
|
||||
if (isc_result != ISC_R_SUCCESS) {
|
||||
t_info("isc_task_send failed %s\n",
|
||||
isc_result_totext(isc_result));
|
||||
isc_timermgr_destroy(&timermgr);
|
||||
(void) isc_mutex_unlock(&T5_mx);
|
||||
isc_task_destroy(&T5_task1);
|
||||
isc_taskmgr_destroy(&tmgr);
|
||||
isc_mutex_destroy(&T5_mx);
|
||||
isc_condition_destroy(&T5_cv);
|
||||
isc_mem_destroy(&mctx);
|
||||
return(T_UNRESOLVED);
|
||||
}
|
||||
isc_task_send(T5_task1, &event);
|
||||
|
||||
isc_time_settoepoch(&expires);
|
||||
isc_interval_set(&interval, T5_SECONDS, 0);
|
||||
|
@@ -37,13 +37,6 @@
|
||||
|
||||
#include "../isc/util.h"
|
||||
|
||||
/*
|
||||
* If we cannot send to this task, the application is broken.
|
||||
*/
|
||||
#define ISC_TASK_SEND(a, b) do { \
|
||||
RUNTIME_CHECK(isc_task_send(a, b) == ISC_R_SUCCESS); \
|
||||
} while (0)
|
||||
|
||||
#ifdef DISPATCH_DEBUG
|
||||
#define XDEBUG(x) printf x
|
||||
#else
|
||||
@@ -538,7 +531,7 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in)
|
||||
rev, rev->buffer.base, rev->buffer.length,
|
||||
resp->task, resp));
|
||||
resp->item_out = ISC_TRUE;
|
||||
ISC_TASK_SEND(resp->task, (isc_event_t **)&rev);
|
||||
isc_task_send(resp->task, (isc_event_t **)&rev);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -711,7 +704,7 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in)
|
||||
rev, rev->buffer.base, rev->buffer.length,
|
||||
resp->task, resp));
|
||||
resp->item_out = ISC_TRUE;
|
||||
ISC_TASK_SEND(resp->task, (isc_event_t **)&rev);
|
||||
isc_task_send(resp->task, (isc_event_t **)&rev);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1345,7 +1338,7 @@ do_next_response(dns_dispatch_t *disp, dns_dispentry_t *resp)
|
||||
resp->item_out = ISC_TRUE;
|
||||
XDEBUG(("Sent event %p for buffer %p (len %d) to task %p, resp %p\n",
|
||||
ev, ev->buffer.base, ev->buffer.length, resp->task, resp));
|
||||
ISC_TASK_SEND(resp->task, (isc_event_t **)&ev);
|
||||
isc_task_send(resp->task, (isc_event_t **)&ev);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1369,7 +1362,7 @@ do_next_request(dns_dispatch_t *disp, dns_dispentry_t *resp)
|
||||
resp->item_out = ISC_TRUE;
|
||||
XDEBUG(("Sent event %p for buffer %p (len %d) to task %p, resp %p\n",
|
||||
ev, ev->buffer.base, ev->buffer.length, resp->task, resp));
|
||||
ISC_TASK_SEND(resp->task, (isc_event_t **)&ev);
|
||||
isc_task_send(resp->task, (isc_event_t **)&ev);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1438,7 +1431,7 @@ do_cancel(dns_dispatch_t *disp, dns_dispentry_t *resp)
|
||||
XDEBUG(("Sending failsafe event %p to task %p, resp %p\n",
|
||||
ev, resp->task, resp));
|
||||
resp->item_out = ISC_TRUE;
|
||||
ISC_TASK_SEND(resp->task, (isc_event_t **)&ev);
|
||||
isc_task_send(resp->task, (isc_event_t **)&ev);
|
||||
}
|
||||
|
||||
isc_socket_t *
|
||||
|
@@ -187,7 +187,6 @@ static void
|
||||
fctx_done(fetchctx_t *fctx, dns_result_t result) {
|
||||
dns_fetchdoneevent_t *event, *next_event;
|
||||
isc_task_t *task;
|
||||
isc_result_t iresult;
|
||||
|
||||
/*
|
||||
* The caller must be holding the proper lock.
|
||||
@@ -206,14 +205,7 @@ fctx_done(fetchctx_t *fctx, dns_result_t result) {
|
||||
task = event->sender;
|
||||
event->sender = fctx;
|
||||
event->result = result;
|
||||
iresult = isc_task_send(task, (isc_event_t **)&event);
|
||||
if (iresult != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_task_send(): %s",
|
||||
isc_result_totext(iresult));
|
||||
isc_event_free((isc_event_t **)&event);
|
||||
}
|
||||
isc_task_detach(&task);
|
||||
isc_task_sendanddetach(&task, (isc_event_t **)&event);
|
||||
}
|
||||
ISC_LIST_INIT(fctx->events);
|
||||
}
|
||||
@@ -720,14 +712,7 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
|
||||
event = &fctx->start_event;
|
||||
ISC_EVENT_INIT(event, sizeof *event, 0, NULL, DNS_EVENT_FETCH,
|
||||
fctx_start, fctx, (void *)fctx_create, NULL, NULL);
|
||||
iresult = isc_task_send(worker, &event);
|
||||
if (iresult != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_task_send: %s",
|
||||
isc_result_totext(iresult));
|
||||
result = DNS_R_UNEXPECTED;
|
||||
goto cleanup_timer;
|
||||
}
|
||||
isc_task_send(worker, &event);
|
||||
|
||||
return (DNS_R_SUCCESS);
|
||||
|
||||
|
@@ -35,13 +35,6 @@
|
||||
|
||||
#include "../isc/util.h"
|
||||
|
||||
/*
|
||||
* If we cannot send to this task, the application is broken.
|
||||
*/
|
||||
#define ISC_TASK_SEND(a, b) do { \
|
||||
RUNTIME_CHECK(isc_task_send(a, b) == ISC_R_SUCCESS); \
|
||||
} while (0)
|
||||
|
||||
#ifdef TCPMSG_DEBUG
|
||||
#define XDEBUG(x) printf x
|
||||
#else
|
||||
@@ -108,7 +101,7 @@ recv_length(isc_task_t *task, isc_event_t *ev_in)
|
||||
return;
|
||||
|
||||
send_and_free:
|
||||
ISC_TASK_SEND(tcpmsg->task, &dev);
|
||||
isc_task_send(tcpmsg->task, &dev);
|
||||
tcpmsg->task = NULL;
|
||||
isc_event_free(&ev_in);
|
||||
return;
|
||||
@@ -139,7 +132,7 @@ recv_message(isc_task_t *task, isc_event_t *ev_in)
|
||||
XDEBUG(("Received %d bytes (of %d)\n", ev->n, tcpmsg->size));
|
||||
|
||||
send_and_free:
|
||||
ISC_TASK_SEND(tcpmsg->task, &dev);
|
||||
isc_task_send(tcpmsg->task, &dev);
|
||||
tcpmsg->task = NULL;
|
||||
isc_event_free(&ev_in);
|
||||
}
|
||||
|
@@ -48,17 +48,6 @@
|
||||
#define ISC_SOCKADDR_LEN_T unsigned int
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If we cannot send to this task, the application is broken.
|
||||
*/
|
||||
#define ISC_TASK_SEND(a, b) do { \
|
||||
RUNTIME_CHECK(isc_task_send(a, b) == ISC_R_SUCCESS); \
|
||||
} while (0)
|
||||
|
||||
#define ISC_TASK_SENDANDDETACH(a, b) do { \
|
||||
RUNTIME_CHECK(isc_task_sendanddetach(a, b) == ISC_R_SUCCESS); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Define what the possible "soft" errors can be. These are non-fatal returns
|
||||
* of various network related functions, like recv() and so on.
|
||||
@@ -1097,7 +1086,7 @@ dispatch_read(isc_socket_t *sock)
|
||||
iev->action = internal_recv;
|
||||
iev->arg = sock;
|
||||
|
||||
ISC_TASK_SEND(ev->sender, (isc_event_t **)&iev);
|
||||
isc_task_send(ev->sender, (isc_event_t **)&iev);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1121,7 +1110,7 @@ dispatch_write(isc_socket_t *sock)
|
||||
iev->action = internal_send;
|
||||
iev->arg = sock;
|
||||
|
||||
ISC_TASK_SEND(ev->sender, (isc_event_t **)&iev);
|
||||
isc_task_send(ev->sender, (isc_event_t **)&iev);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1145,7 +1134,7 @@ dispatch_accept(isc_socket_t *sock)
|
||||
iev->action = internal_accept;
|
||||
iev->arg = sock;
|
||||
|
||||
ISC_TASK_SEND(ev->sender, (isc_event_t **)&iev);
|
||||
isc_task_send(ev->sender, (isc_event_t **)&iev);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1166,7 +1155,7 @@ dispatch_connect(isc_socket_t *sock)
|
||||
iev->action = internal_connect;
|
||||
iev->arg = sock;
|
||||
|
||||
ISC_TASK_SEND(ev->sender, (isc_event_t **)&iev);
|
||||
isc_task_send(ev->sender, (isc_event_t **)&iev);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1195,9 +1184,9 @@ send_recvdone_event(isc_socket_t *sock, isc_socketevent_t **dev,
|
||||
|
||||
if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED)
|
||||
== ISC_SOCKEVENTATTR_ATTACHED)
|
||||
ISC_TASK_SENDANDDETACH(&task, (isc_event_t **)dev);
|
||||
isc_task_sendanddetach(&task, (isc_event_t **)dev);
|
||||
else
|
||||
ISC_TASK_SEND(task, (isc_event_t **)dev);
|
||||
isc_task_send(task, (isc_event_t **)dev);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1221,9 +1210,9 @@ send_senddone_event(isc_socket_t *sock, isc_socketevent_t **dev,
|
||||
|
||||
if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED)
|
||||
== ISC_SOCKEVENTATTR_ATTACHED)
|
||||
ISC_TASK_SENDANDDETACH(&task, (isc_event_t **)dev);
|
||||
isc_task_sendanddetach(&task, (isc_event_t **)dev);
|
||||
else
|
||||
ISC_TASK_SEND(task, (isc_event_t **)dev);
|
||||
isc_task_send(task, (isc_event_t **)dev);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1368,7 +1357,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev)
|
||||
task = dev->sender;
|
||||
dev->sender = sock;
|
||||
|
||||
ISC_TASK_SENDANDDETACH(&task, (isc_event_t **)&dev);
|
||||
isc_task_sendanddetach(&task, (isc_event_t **)&dev);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2561,7 +2550,7 @@ isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr,
|
||||
|
||||
err_exit:
|
||||
sock->connected = 0;
|
||||
ISC_TASK_SEND(task, (isc_event_t **)&dev);
|
||||
isc_task_send(task, (isc_event_t **)&dev);
|
||||
|
||||
UNLOCK(&sock->lock);
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -2573,7 +2562,7 @@ isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr,
|
||||
if (cc == 0) {
|
||||
sock->connected = 1;
|
||||
dev->result = ISC_R_SUCCESS;
|
||||
ISC_TASK_SEND(task, (isc_event_t **)&dev);
|
||||
isc_task_send(task, (isc_event_t **)&dev);
|
||||
|
||||
UNLOCK(&sock->lock);
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -2703,7 +2692,7 @@ internal_connect(isc_task_t *me, isc_event_t *ev)
|
||||
|
||||
task = dev->sender;
|
||||
dev->sender = sock;
|
||||
ISC_TASK_SENDANDDETACH(&task, (isc_event_t **)&dev);
|
||||
isc_task_sendanddetach(&task, (isc_event_t **)&dev);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -2834,7 +2823,7 @@ isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how)
|
||||
|
||||
dev->result = ISC_R_CANCELED;
|
||||
dev->sender = sock;
|
||||
ISC_TASK_SENDANDDETACH(¤t_task,
|
||||
isc_task_sendanddetach(¤t_task,
|
||||
(isc_event_t **)&dev);
|
||||
}
|
||||
|
||||
@@ -2858,7 +2847,7 @@ isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how)
|
||||
|
||||
dev->result = ISC_R_CANCELED;
|
||||
dev->sender = sock;
|
||||
ISC_TASK_SENDANDDETACH(¤t_task,
|
||||
isc_task_sendanddetach(¤t_task,
|
||||
(isc_event_t **)&dev);
|
||||
}
|
||||
}
|
||||
@@ -2908,7 +2897,7 @@ isc_socket_recvmark(isc_socket_t *sock,
|
||||
if (EMPTY(sock->recv_list)) {
|
||||
dev->result = sock->recv_result;
|
||||
|
||||
ISC_TASK_SEND(task, (isc_event_t **)&dev);
|
||||
isc_task_send(task, (isc_event_t **)&dev);
|
||||
|
||||
UNLOCK(&sock->lock);
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -2969,7 +2958,7 @@ isc_socket_sendmark(isc_socket_t *sock,
|
||||
if (EMPTY(sock->send_list)) {
|
||||
dev->result = sock->send_result;
|
||||
|
||||
ISC_TASK_SEND(task, (isc_event_t **)&dev);
|
||||
isc_task_send(task, (isc_event_t **)&dev);
|
||||
|
||||
UNLOCK(&sock->lock);
|
||||
return (ISC_R_SUCCESS);
|
||||
|
Reference in New Issue
Block a user