From 55c59e6153509887463d258c41c87c100f7f851f Mon Sep 17 00:00:00 2001 From: behlendo Date: Tue, 4 Nov 2008 22:39:29 +0000 Subject: [PATCH] Add proper error handling to one of the atomic test cases in the event that a kernel thread cannot be properly spawned. git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@168 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c --- modules/splat/splat-atomic.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/splat/splat-atomic.c b/modules/splat/splat-atomic.c index 05afdb6..cc947d0 100644 --- a/modules/splat/splat-atomic.c +++ b/modules/splat/splat-atomic.c @@ -126,9 +126,9 @@ splat_atomic_work(void *priv) } static int -splat_atomic_test1_cond(atomic_priv_t *ap) +splat_atomic_test1_cond(atomic_priv_t *ap, int started) { - return (ap->ap_atomic_exited == SPLAT_ATOMIC_COUNT_64); + return (ap->ap_atomic_exited == started); } static int @@ -137,7 +137,7 @@ splat_atomic_test1(struct file *file, void *arg) atomic_priv_t ap; DEFINE_WAIT(wait); kthread_t *thr; - int i; + int i, rc = 0; ap.ap_magic = SPLAT_ATOMIC_TEST_MAGIC; ap.ap_file = file; @@ -153,7 +153,11 @@ splat_atomic_test1(struct file *file, void *arg) thr = (kthread_t *)thread_create(NULL, 0, splat_atomic_work, &ap, 0, &p0, TS_RUN, minclsyspri); - ASSERT(thr); + if (thr == NULL) { + rc = -ESRCH; + spin_unlock(&ap.ap_lock); + break; + } /* Prepare to wait, the new thread will wake us once it * has made a copy of the unique private passed data */ @@ -162,7 +166,13 @@ splat_atomic_test1(struct file *file, void *arg) schedule(); } - wait_event_interruptible(ap.ap_waitq, splat_atomic_test1_cond(&ap)); + wait_event_interruptible(ap.ap_waitq, splat_atomic_test1_cond(&ap, i)); + + if (rc) { + splat_vprint(file, SPLAT_ATOMIC_TEST1_NAME, "Only started " + "%d/%d test threads\n", i, SPLAT_ATOMIC_COUNT_64); + return rc; + } if (ap.ap_atomic != SPLAT_ATOMIC_INIT_VALUE) { splat_vprint(file, SPLAT_ATOMIC_TEST1_NAME, -- 2.39.2