shutdown_test.c revision 271d5bfc5ca8d746b535d1522f2aa9389ece2a7e
7d32c065c7bb56f281651ae3dd2888f32ce4f1d9Bob Halley * Copyright (C) 1998, 1999 Internet Software Consortium.
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * Permission to use, copy, modify, and distribute this software for any
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * purpose with or without fee is hereby granted, provided that the above
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
15a44745412679c30a6d022733925af70a38b715David Lawrence * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
15a44745412679c30a6d022733925af70a38b715David Lawrence * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
15a44745412679c30a6d022733925af70a38b715David Lawrence * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15a44745412679c30a6d022733925af70a38b715David Lawrence * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15a44745412679c30a6d022733925af70a38b715David Lawrence * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
15a44745412679c30a6d022733925af70a38b715David Lawrence * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleytypedef struct {
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence unsigned int ticks;
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley#define T2_SHUTDOWNDONE (ISC_EVENTCLASS(1024) + 1)
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleystatic unsigned int task_count;
1ccbfca64ae86ace521053773001cb995352f96fBob Halleyt1_shutdown(isc_task_t *task, isc_event_t *event) {
1ccbfca64ae86ace521053773001cb995352f96fBob Halley printf("task %s (%p) t1_shutdown\n", info->name, task);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleyt2_shutdown(isc_task_t *task, isc_event_t *event) {
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley printf("task %s (%p) t2_shutdown\n", info->name, task);
1ccbfca64ae86ace521053773001cb995352f96fBob Halleyshutdown_action(isc_task_t *task, isc_event_t *event) {
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley printf("task %s (%p) shutdown\n", info->name, task);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley nevent = isc_event_allocate(info->mctx, info, T2_SHUTDOWNOK,
1ccbfca64ae86ace521053773001cb995352f96fBob Halley RUNTIME_CHECK(isc_app_shutdown() == ISC_R_SUCCESS);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley RUNTIME_CHECK(isc_task_create(task_manager, mctx, 0, &ti->task) ==
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence RUNTIME_CHECK(isc_task_onshutdown(ti->task, shutdown_action, ti) ==
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews RUNTIME_CHECK(isc_timer_create(timer_manager, isc_timertype_ticker,
a6733246eafeb43755ce6d7ec3627ac4209cbccbMark Andrews unsigned int workers;
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley RUNTIME_CHECK(isc_mem_create(0, 0, &mctx2) == ISC_R_SUCCESS);
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &task_manager) ==
b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81Bob Halley RUNTIME_CHECK(isc_timermgr_create(mctx, &timer_manager) ==
fe12eb4fc27f49c6b3e42b1d7a6b40310e41e6dfBrian Wellington * Test run-triggered shutdown.
a99979c686ae04efd55ba8f0aacf32493b4aa7faBob Halley * Test implicit shutdown.
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley RUNTIME_CHECK(isc_task_create(task_manager, mctx, 0, &task) ==
a99979c686ae04efd55ba8f0aacf32493b4aa7faBob Halley * Test anti-zombie code.