diff --git a/bin/tests/sock_test.c b/bin/tests/sock_test.c index ecc711b4dd..9bf44f8cee 100644 --- a/bin/tests/sock_test.c +++ b/bin/tests/sock_test.c @@ -40,10 +40,10 @@ isc_memctx_t *mctx = NULL; int sockets_active = 0; -static isc_boolean_t my_send(isc_task_t *task, isc_event_t *event); -static isc_boolean_t my_recv(isc_task_t *task, isc_event_t *event); +static void my_send(isc_task_t *task, isc_event_t *event); +static void my_recv(isc_task_t *task, isc_event_t *event); -static isc_boolean_t +static void my_callback(isc_task_t *task, isc_event_t *event) { char *name = event->arg; @@ -51,11 +51,9 @@ my_callback(isc_task_t *task, isc_event_t *event) printf("task %s (%p)\n", name, task); fflush(stdout); isc_event_free(&event); - - return (ISC_FALSE); } -static isc_boolean_t +static void my_shutdown(isc_task_t *task, isc_event_t *event) { char *name = event->arg; @@ -63,11 +61,9 @@ my_shutdown(isc_task_t *task, isc_event_t *event) printf("shutdown %s (%p)\n", name, task); fflush(stdout); isc_event_free(&event); - - return (ISC_TRUE); } -static isc_boolean_t +static void my_recv(isc_task_t *task, isc_event_t *event) { isc_socket_t *sock; @@ -93,9 +89,8 @@ my_recv(isc_task_t *task, isc_event_t *event) sockets_active--; if (sockets_active == 0) - return (1); - - return (0); + isc_task_shutdown(task); + return; } /* @@ -120,11 +115,9 @@ my_recv(isc_task_t *task, isc_event_t *event) isc_event_free(&event); - - return (0); } -static isc_boolean_t +static void my_send(isc_task_t *task, isc_event_t *event) { isc_socket_t *sock; @@ -141,11 +134,9 @@ my_send(isc_task_t *task, isc_event_t *event) isc_mem_put(event->mctx, dev->region.base, dev->region.length); isc_event_free(&event); - - return (0); } -static isc_boolean_t +static void my_http_get(isc_task_t *task, isc_event_t *event) { isc_socket_t *sock; @@ -163,11 +154,9 @@ my_http_get(isc_task_t *task, isc_event_t *event) event->arg); isc_event_free(&event); - - return (0); } -static isc_boolean_t +static void my_connect(isc_task_t *task, isc_event_t *event) { isc_socket_t *sock; @@ -184,8 +173,7 @@ my_connect(isc_task_t *task, isc_event_t *event) if (dev->result != ISC_R_SUCCESS) { isc_socket_detach(&sock); isc_event_free(&event); - - return (0); + return; } /* @@ -200,18 +188,15 @@ my_connect(isc_task_t *task, isc_event_t *event) isc_socket_send(sock, ®ion, task, my_http_get, event->arg); isc_event_free(&event); - - return (0); } -static isc_boolean_t +static void my_listen(isc_task_t *task, isc_event_t *event) { char *name = event->arg; isc_socket_newconnev_t *dev; isc_region_t region; isc_socket_t *oldsock; - int ret; dev = (isc_socket_newconnev_t *)event; @@ -219,8 +204,6 @@ my_listen(isc_task_t *task, isc_event_t *event) name, task, event->sender, dev->newsocket, dev->result); fflush(stdout); - ret = 0; - if (dev->result == ISC_R_SUCCESS) { /* * queue another listen on this socket @@ -243,15 +226,14 @@ my_listen(isc_task_t *task, isc_event_t *event) isc_socket_detach(&oldsock); sockets_active--; - ret = 1; + isc_task_shutdown(task); + return; } isc_event_free(&event); - - return (ret); } -static isc_boolean_t +static void timeout(isc_task_t *task, isc_event_t *event) { isc_socket_t *sock = event->arg; @@ -260,8 +242,6 @@ timeout(isc_task_t *task, isc_event_t *event) isc_socket_cancel(sock, NULL, ISC_SOCKCANCEL_ALL); isc_timer_detach((isc_timer_t **)&event->sender); - - return (0); } int @@ -296,10 +276,10 @@ main(int argc, char *argv[]) INSIST(isc_taskmgr_create(mctx, workers, 0, &manager) == ISC_R_SUCCESS); - INSIST(isc_task_create(manager, my_shutdown, "1", 0, &t1) == - ISC_R_SUCCESS); - INSIST(isc_task_create(manager, my_shutdown, "2", 0, &t2) == - ISC_R_SUCCESS); + INSIST(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS); + INSIST(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS); + INSIST(isc_task_onshutdown(t1, my_shutdown, "1") == ISC_R_SUCCESS); + INSIST(isc_task_onshutdown(t2, my_shutdown, "2") == ISC_R_SUCCESS); printf("task 1 = %p\n", t1); printf("task 2 = %p\n", t2); diff --git a/bin/tests/task_test.c b/bin/tests/task_test.c index 5a237fdc21..36478f9284 100644 --- a/bin/tests/task_test.c +++ b/bin/tests/task_test.c @@ -30,7 +30,7 @@ isc_memctx_t *mctx = NULL; -static isc_boolean_t +static void my_callback(isc_task_t *task, isc_event_t *event) { int i, j; @@ -41,29 +41,23 @@ my_callback(isc_task_t *task, isc_event_t *event) j += 100; printf("task %s (%p): %d\n", name, task, j); isc_event_free(&event); - - return (ISC_FALSE); } -static isc_boolean_t +static void my_shutdown(isc_task_t *task, isc_event_t *event) { char *name = event->arg; printf("shutdown %s (%p)\n", name, task); isc_event_free(&event); - - return (ISC_TRUE); } -static isc_boolean_t +static void my_tick(isc_task_t *task, isc_event_t *event) { char *name = event->arg; printf("task %p tick %s\n", task, name); isc_event_free(&event); - - return (ISC_FALSE); } void @@ -89,14 +83,15 @@ main(int argc, char *argv[]) { INSIST(isc_taskmgr_create(mctx, workers, 0, &manager) == ISC_R_SUCCESS); - INSIST(isc_task_create(manager, my_shutdown, "1", 0, &t1) == - ISC_R_SUCCESS); - INSIST(isc_task_create(manager, my_shutdown, "2", 0, &t2) == - ISC_R_SUCCESS); - INSIST(isc_task_create(manager, my_shutdown, "3", 0, &t3) == - ISC_R_SUCCESS); - INSIST(isc_task_create(manager, my_shutdown, "4", 0, &t4) == - ISC_R_SUCCESS); + INSIST(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS); + INSIST(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS); + INSIST(isc_task_create(manager, 0, &t3) == ISC_R_SUCCESS); + INSIST(isc_task_create(manager, 0, &t4) == ISC_R_SUCCESS); + + INSIST(isc_task_onshutdown(t1, my_shutdown, "1") == ISC_R_SUCCESS); + INSIST(isc_task_onshutdown(t2, my_shutdown, "2") == ISC_R_SUCCESS); + INSIST(isc_task_onshutdown(t3, my_shutdown, "3") == ISC_R_SUCCESS); + INSIST(isc_task_onshutdown(t4, my_shutdown, "4") == ISC_R_SUCCESS); timgr = NULL; INSIST(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS); diff --git a/bin/tests/timer_test.c b/bin/tests/timer_test.c index f74b91ab45..7c1a489d26 100644 --- a/bin/tests/timer_test.c +++ b/bin/tests/timer_test.c @@ -33,17 +33,15 @@ isc_task_t *t1, *t2, *t3; isc_timer_t *ti1, *ti2, *ti3; int tick_count = 0; -static isc_boolean_t +static void shutdown_task(isc_task_t *task, isc_event_t *event) { char *name = event->arg; printf("task %p shutdown %s\n", task, name); isc_event_free(&event); - - return (ISC_TRUE); } -static isc_boolean_t +static void tick(isc_task_t *task, isc_event_t *event) { char *name = event->arg; @@ -71,11 +69,9 @@ tick(isc_task_t *task, isc_event_t *event) } isc_event_free(&event); - - return (ISC_FALSE); } -static isc_boolean_t +static void timeout(isc_task_t *task, isc_event_t *event) { char *name = event->arg; @@ -93,12 +89,11 @@ timeout(isc_task_t *task, isc_event_t *event) if (strcmp(name, "3") == 0) { printf("*** saving task 3 ***\n"); isc_event_free(&event); - return (ISC_FALSE); + return; } isc_event_free(&event); - - return (ISC_TRUE); + isc_task_shutdown(task); } void @@ -118,14 +113,15 @@ main(int argc, char *argv[]) { INSIST(isc_memctx_create(0, 0, &mctx) == ISC_R_SUCCESS); INSIST(isc_taskmgr_create(mctx, workers, 0, &manager) == ISC_R_SUCCESS); - INSIST(isc_task_create(manager, shutdown_task, "1", 0, &t1) == - ISC_R_SUCCESS); - INSIST(isc_task_create(manager, shutdown_task, "2", 0, &t2) == - ISC_R_SUCCESS); - INSIST(isc_task_create(manager, shutdown_task, "3", 0, &t3) == - ISC_R_SUCCESS); INSIST(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS); + INSIST(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS); + INSIST(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS); + INSIST(isc_task_create(manager, 0, &t3) == ISC_R_SUCCESS); + INSIST(isc_task_onshutdown(t1, shutdown_task, "1") == ISC_R_SUCCESS); + INSIST(isc_task_onshutdown(t2, shutdown_task, "2") == ISC_R_SUCCESS); + INSIST(isc_task_onshutdown(t3, shutdown_task, "3") == ISC_R_SUCCESS); + printf("task 1: %p\n", t1); printf("task 2: %p\n", t2); printf("task 3: %p\n", t3); diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 7f346651cf..35e38065cb 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -163,10 +163,10 @@ static void free_socket(isc_socket_t **); static isc_result_t allocate_socket(isc_socketmgr_t *, isc_sockettype_t, isc_socket_t **); static void destroy(isc_socket_t **); -static isc_boolean_t internal_accept(isc_task_t *, isc_event_t *); -static isc_boolean_t internal_connect(isc_task_t *, isc_event_t *); -static isc_boolean_t internal_recv(isc_task_t *, isc_event_t *); -static isc_boolean_t internal_send(isc_task_t *, isc_event_t *); +static void internal_accept(isc_task_t *, isc_event_t *); +static void internal_connect(isc_task_t *, isc_event_t *); +static void internal_recv(isc_task_t *, isc_event_t *); +static void internal_send(isc_task_t *, isc_event_t *); #define SELECT_POKE_SHUTDOWN (-1) #define SELECT_POKE_NOTHING (-2) @@ -307,8 +307,6 @@ done_event_destroy(isc_event_t *ev) if (kill_socket) destroy(&sock); - - /* XXXRTH looks like we're leaking the done event here... */ } /* @@ -692,7 +690,7 @@ send_ncdone_event(ncintev_t **iev, * message, and once for the message itself) so the task does not need to * attach to the socket again. The task is not attached at all. */ -static isc_boolean_t +static void internal_accept(isc_task_t *task, isc_event_t *ev) { isc_socket_t *sock; @@ -733,7 +731,7 @@ internal_accept(isc_task_t *task, isc_event_t *ev) UNLOCK(&sock->lock); - return (ISC_FALSE); + return; } /* @@ -747,7 +745,7 @@ internal_accept(isc_task_t *task, isc_event_t *ev) if (SOFT_ERROR(errno)) { select_poke(sock->manager, sock->fd); UNLOCK(&sock->lock); - return (ISC_FALSE); + return; } /* @@ -817,11 +815,9 @@ internal_accept(isc_task_t *task, isc_event_t *ev) } send_ncdone_event(&iev, &dev, result); - - return (ISC_FALSE); } -static isc_boolean_t +static void internal_recv(isc_task_t *task, isc_event_t *ev) { rwintev_t *iev; @@ -977,11 +973,9 @@ internal_recv(isc_task_t *task, isc_event_t *ev) select_poke(sock->manager, sock->fd); UNLOCK(&sock->lock); - - return (ISC_FALSE); } -static isc_boolean_t +static void internal_send(isc_task_t *task, isc_event_t *ev) { rwintev_t *iev; @@ -1113,8 +1107,6 @@ internal_send(isc_task_t *task, isc_event_t *ev) select_poke(sock->manager, sock->fd); UNLOCK(&sock->lock); - - return (ISC_FALSE); } /* @@ -2095,7 +2087,7 @@ isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr, int addrlen, /* * Called when a socket with a pending connect() finishes. */ -static isc_boolean_t +static void internal_connect(isc_task_t *task, isc_event_t *ev) { isc_socket_t *sock; @@ -2127,7 +2119,7 @@ internal_connect(isc_task_t *task, isc_event_t *ev) UNLOCK(&sock->lock); - return (ISC_FALSE); + return; } dev = iev->done_ev; @@ -2152,7 +2144,7 @@ internal_connect(isc_task_t *task, isc_event_t *ev) select_poke(sock->manager, sock->fd); UNLOCK(&sock->lock); - return (ISC_FALSE); + return; } /* @@ -2183,8 +2175,6 @@ internal_connect(isc_task_t *task, isc_event_t *ev) ISC_TASK_SEND(iev->task, (isc_event_t **)&dev); iev->done_ev = NULL; isc_event_free((isc_event_t **)&iev); - - return (ISC_FALSE); } isc_result_t