From cbf59e5887d69fca6fe86a1ee5fcc82dded14bab Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 18 Mar 2011 07:40:25 +0000 Subject: [PATCH] 3079. [bug] Handle isc_event_allocate failures in t_tasks. [RT #23572] --- CHANGES | 3 ++ bin/tests/tasks/t_tasks.c | 76 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index b4508817b9..62f7753ee0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3079. [bug] Handle isc_event_allocate failures in t_tasks. + [RT #23572] + 3078. [func] Added a new include file with function typedefs for the DLZ "dlopen" driver. [RT #23629] diff --git a/bin/tests/tasks/t_tasks.c b/bin/tests/tasks/t_tasks.c index d71dde5312..a889efdb13 100644 --- a/bin/tests/tasks/t_tasks.c +++ b/bin/tests/tasks/t_tasks.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_tasks.c,v 1.45 2011/03/14 14:10:23 fdupont Exp $ */ +/* $Id: t_tasks.c,v 1.46 2011/03/18 07:40:25 marka Exp $ */ #include @@ -744,6 +744,14 @@ t_tasks3(void) { */ event = isc_event_allocate(mctx, &senders[1], event_type, t3_event1, NULL, sizeof(*event)); + if (event == NULL) { + t_info("isc_event_allocate failed\n"); + (void) isc_mutex_unlock(&T3_mx); + isc_task_destroy(&task); + isc_taskmgr_destroy(&tmgr); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } isc_task_send(task, &event); /* @@ -752,6 +760,14 @@ t_tasks3(void) { for (cnt = 0; cnt < T3_NEVENTS; ++cnt) { event = isc_event_allocate(mctx, &senders[1], event_type, t3_event2, NULL, sizeof(*event)); + if (event == NULL) { + t_info("isc_event_allocate failed\n"); + (void) isc_mutex_unlock(&T3_mx); + isc_task_destroy(&task); + isc_taskmgr_destroy(&tmgr); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } isc_task_send(task, &event); } @@ -963,6 +979,15 @@ t_tasks4(void) { */ event = isc_event_allocate(mctx, &senders[1], event_type, t4_event1, NULL, sizeof(*event)); + if (event == NULL) { + t_info("isc_event_allocate failed\n"); + DESTROYLOCK(&T4_mx); + isc_task_destroy(&task); + (void) isc_condition_destroy(&T4_cv); + isc_taskmgr_destroy(&tmgr); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } isc_task_send(task, &event); isc_task_shutdown(task); @@ -1171,6 +1196,15 @@ t_tasks7(void) { event = isc_event_allocate(mctx, &senders[1], event_type, t7_event1, NULL, sizeof(*event)); + if (event == NULL) { + t_info("isc_event_allocate failed\n"); + DESTROYLOCK(&T7_mx); + (void) isc_condition_destroy(&T7_cv); + isc_task_destroy(&task); + isc_taskmgr_destroy(&tmgr); + isc_mem_destroy(&mctx); + return(T_UNRESOLVED); + } isc_task_send(task, &event); isc_task_shutdown(task); @@ -1495,6 +1529,16 @@ t_taskpurge_x(int sender, int type, int tag, void *purge_sender, event = isc_event_allocate(mctx, (void *)1, (isc_eventtype_t)T_CONTROL, t10_event1, NULL, sizeof(*event)); + if (event == NULL) { + t_info("isc_event_allocate failed\n"); + isc_task_destroy(&task); + isc_taskmgr_destroy(&tmgr); + isc_mem_destroy(&mctx); + DESTROYLOCK(&T10_mx); + (void) isc_condition_destroy(&T10_cv); + ++*nprobs; + return; + } isc_task_send(task, &event); /* @@ -1512,6 +1556,17 @@ t_taskpurge_x(int sender, int type, int tag, void *purge_sender, (isc_eventtype_t)(type + type_cnt), t10_event2, NULL, sizeof(*event)); + if (eventtab[event_cnt] == NULL) { + t_info("isc_event_allocate failed\n"); + isc_task_destroy(&task); + isc_taskmgr_destroy(&tmgr); + isc_mem_destroy(&mctx); + DESTROYLOCK(&T10_mx); + (void) isc_condition_destroy(&T10_cv); + ++*nprobs; + return; + } + eventtab[event_cnt]->ev_tag = (void *)((uintptr_t)tag + tag_cnt); @@ -1883,11 +1938,28 @@ t_tasks11(int purgable) { */ event1 = isc_event_allocate(mctx, (void *)1, (isc_eventtype_t)1, t11_event1, NULL, sizeof(*event1)); - + if (event1 == NULL) { + t_info("isc_event_allocate failed\n"); + isc_task_destroy(&task); + isc_taskmgr_destroy(&tmgr); + isc_mem_destroy(&mctx); + DESTROYLOCK(&T11_mx); + (void) isc_condition_destroy(&T11_cv); + return(T_UNRESOLVED); + } isc_task_send(task, &event1); event2 = isc_event_allocate(mctx, (void *)1, (isc_eventtype_t)1, t11_event2, NULL, sizeof(*event2)); + if (event2 == NULL) { + t_info("isc_event_allocate failed\n"); + isc_task_destroy(&task); + isc_taskmgr_destroy(&tmgr); + isc_mem_destroy(&mctx); + DESTROYLOCK(&T11_mx); + (void) isc_condition_destroy(&T11_cv); + return(T_UNRESOLVED); + } event2_clone = event2; if (purgable) event2->ev_attributes &= ~ISC_EVENTATTR_NOPURGE;