From 91d10a7d516a71af91ff455f59f9db2a6ef932be Mon Sep 17 00:00:00 2001 From: Gregory Burd Date: Sun, 4 Dec 2011 14:46:13 -0500 Subject: [PATCH] Error messages --- c_src/bdberl_drv.c | 3 ++- c_src/bdberl_tpool.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/c_src/bdberl_drv.c b/c_src/bdberl_drv.c index 721f3e2..570f53b 100644 --- a/c_src/bdberl_drv.c +++ b/c_src/bdberl_drv.c @@ -321,8 +321,9 @@ DRIVER_INIT(bdberl_drv) // cleanup and set the environment to zero. Attempts to open ports will // fail and the user will have to sort out how to resolve the issue. DBG("G_DB_ENV->close(%p, 0);", &G_DB_ENV); - G_DB_ENV->close(G_DB_ENV, 0); + G_DB_ENV_ERROR = G_DB_ENV->close(G_DB_ENV, 0); G_DB_ENV = 0; + DBG(" = %d\n", G_DB_ENV_ERROR); } } diff --git a/c_src/bdberl_tpool.c b/c_src/bdberl_tpool.c index e0210c7..41156cd 100644 --- a/c_src/bdberl_tpool.c +++ b/c_src/bdberl_tpool.c @@ -64,10 +64,13 @@ TPool* bdberl_tpool_start(unsigned int thread_count) int i; for (i = 0; i < thread_count; i++) { - // TODO: Figure out good way to deal with errors in this situation (should be rare, but still...) - erl_drv_thread_create("bdberl_tpool_thread", &(tpool->threads[i]), &bdberl_tpool_main, (void*)tpool, 0); + int rc = erl_drv_thread_create("bdberl_tpool_thread", &(tpool->threads[i]), &bdberl_tpool_main, (void*)tpool, 0); + if (0 != rc) { + // TODO: Figure out good way to deal with errors in this situation (should be rare, but still...) + fprintf(stderr, "Failed to spawn an erlang thread for the BDB thread pools! %s\n", erl_errno_id(rc)); + fflush(stderr); + } } - return tpool; }