branch, ticket-227, updated. efe9ed9084852fb6cf555dffdbef953a51dd4c6c
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "". The branch, ticket-227 has been updated via efe9ed9084852fb6cf555dffdbef953a51dd4c6c (commit) via ff3fc525a3cb52eb1c76c56fb7653ff97fa98832 (commit) via 7e1b4864f5b155f310b8291e8aa4da32828ead1a (commit) via ceb77281ded400639b264c6120e50f07a19f0872 (commit) via c4915a33ded97e9195a0217947c49c00661ccc72 (commit) from eb9b77a5f3b0cd4a46af31bc4e2b72217ec72805 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit efe9ed9084852fb6cf555dffdbef953a51dd4c6c Author: Phil Carns <[email protected]> Date: Fri Dec 14 17:21:52 2012 -0500 remember to finalize triton-debug in bdb rsc commit ff3fc525a3cb52eb1c76c56fb7653ff97fa98832 Author: Phil Carns <[email protected]> Date: Fri Dec 14 17:20:24 2012 -0500 init zeroconf from triton-debug commit 7e1b4864f5b155f310b8291e8aa4da32828ead1a Author: Phil Carns <[email protected]> Date: Fri Dec 14 17:18:19 2012 -0500 clean up init functions in zeroconf component commit ceb77281ded400639b264c6120e50f07a19f0872 Author: Phil Carns <[email protected]> Date: Fri Dec 14 17:10:25 2012 -0500 initialize triton debugging in bdb resource commit c4915a33ded97e9195a0217947c49c00661ccc72 Author: Phil Carns <[email protected]> Date: Fri Dec 14 17:08:42 2012 -0500 clean up init functinos for triton-debug ----------------------------------------------------------------------- Summary of changes: code/src/common/resources/bdb/bdb-resource.c | 17 +++- code/src/common/triton-debug.c | 140 +++++++++++--------------- code/src/common/triton-debug.h | 3 + code/src/zeroconf/zeroconf.c | 48 ++++++--- code/src/zeroconf/zeroconf.h | 3 + 5 files changed, 111 insertions(+), 100 deletions(-) Diff of changes: diff --git a/code/src/common/resources/bdb/bdb-resource.c b/code/src/common/resources/bdb/bdb-resource.c index 91128cc..1f59b49 100644 --- a/code/src/common/resources/bdb/bdb-resource.c +++ b/code/src/common/resources/bdb/bdb-resource.c @@ -429,13 +429,19 @@ triton_ret_t bdb_init(void) if (! bdb_refcount++ ) { - /* @TODO: Need to call init function for dependencies*/ + ret = triton_debug_init(); + if(ret != TRITON_SUCCESS) + { + triton_mutex_unlock (&bdb_ref_mutex); + return(ret); + } /* register a debugging mask for use in this resource */ ret = triton_debug_add_mask("bdb.resource", &bdb_r_mask, "Output debugging information for the Berkeley DB resources"); if(ret != TRITON_SUCCESS) { + triton_debug_finalize(); triton_mutex_unlock (&bdb_ref_mutex); return(ret); } @@ -445,6 +451,7 @@ triton_ret_t bdb_init(void) "Progress mode for BDB transactions (THREAD_PER_OP or THREAD_PER_TXN"); if(ret != TRITON_SUCCESS && ret != TRITON_ERR_EXIST) { + triton_debug_finalize(); triton_mutex_unlock (&bdb_ref_mutex); return(ret); } @@ -454,6 +461,7 @@ triton_ret_t bdb_init(void) "Progress mode for flushing BDB data (IN_PLACE, POLL, THREAD_PER_OP, or ONE_THREAD"); if(ret != TRITON_SUCCESS && ret != TRITON_ERR_EXIST) { + triton_debug_finalize(); triton_mutex_unlock (&bdb_ref_mutex); return(ret); } @@ -465,6 +473,7 @@ triton_ret_t bdb_init(void) &bdb_opcache); if(ae_ret != AE_SUCCESS) { + triton_debug_finalize(); triton_mutex_unlock (&bdb_ref_mutex); return(TRITON_ERR_UNKNOWN); } @@ -472,6 +481,7 @@ triton_ret_t bdb_init(void) txn_thread_table = triton_hash_init(txn_compare, triton_hash_ptr_hash, 200); if(!txn_thread_table) { + triton_debug_finalize(); triton_mutex_unlock (&bdb_ref_mutex); return(TRITON_ERR_NOMEM); } @@ -479,8 +489,9 @@ triton_ret_t bdb_init(void) ae_ret = ae_resource_register(&triton_bdb_resource, &triton_bdb_resource_id); if(ret != AE_SUCCESS) { - triton_mutex_unlock (&bdb_ref_mutex); + triton_debug_finalize(); ae_opcache_destroy(bdb_opcache); + triton_mutex_unlock (&bdb_ref_mutex); return(TRITON_ERR_UNKNOWN); } } @@ -503,7 +514,7 @@ void bdb_finalize(void) triton_debug(bdb_r_mask, "bdb deadlock_counter: %lu\n", deadlock_counter); - /* @TODO: Need to call finalize function for dependencies*/ + triton_debug_finalize(); } triton_mutex_unlock (&bdb_ref_mutex); diff --git a/code/src/common/triton-debug.c b/code/src/common/triton-debug.c index 7c6bca5..b32bebf 100644 --- a/code/src/common/triton-debug.c +++ b/code/src/common/triton-debug.c @@ -8,6 +8,9 @@ #include "src/common/triton-init.h" #include "src/zeroconf/zeroconf.h" +static triton_mutex_t module_lock = TRITON_MUTEX_INITIALIZER; +static int module_refcount = 0; + static struct triton_hash_table *triton_debug_mask_table = NULL; static triton_list_t triton_debug_full_masks; @@ -31,7 +34,6 @@ extern char* __progname_full; #define triton_debug_set(value) triton_bitarray_set(triton_debug_enabled_minor, value-1) static FILE *triton_debug_fp = NULL; -static char *triton_debug_enabled_str = NULL; static uint64_t triton_debug_major_mask_count = 0; static uint64_t triton_debug_mask_count = 0; @@ -63,22 +65,6 @@ static int triton_debug_compare(const void *k, struct triton_hash_link *llink) return !strcmp(k, entry->mask); } -static triton_ret_t triton_debug_init(void); -static void triton_debug_finalize(void); -static triton_ret_t triton_debug_init_stage2(void); - -__attribute__((constructor)) void triton_debug_init_register(void); - -__attribute__((constructor)) void triton_debug_init_register(void) -{ - triton_init_register( - "triton.debug", - triton_debug_init, - triton_debug_finalize, - triton_debug_init_stage2, - "triton.zeroconf"); -} - static triton_ret_t debug_file_updater(const char *key, const char *value) { assert(!strcmp(key, "triton.debug.file")); @@ -91,35 +77,56 @@ static triton_ret_t debug_mask_updater(const char *key, const char *value) return triton_debug_enable(NULL, value); } -static triton_ret_t triton_debug_init(void) +triton_ret_t triton_debug_init(void) { triton_ret_t ret; - triton_debug_mask_table = triton_hash_init(triton_debug_compare, triton_hash_strhash, bj_hashsize(10)); - if(!triton_debug_mask_table) + triton_mutex_lock(&module_lock); + + if(!module_refcount) { - return TRITON_ERR_NOMEM; - } + ret = triton_zeroconf_init(); + if(ret != TRITON_SUCCESS) + { + triton_mutex_unlock(&module_lock); + return(ret); + } + + triton_debug_mask_table = triton_hash_init(triton_debug_compare, triton_hash_strhash, bj_hashsize(10)); + if(!triton_debug_mask_table) + { + triton_zeroconf_finalize(); + triton_mutex_unlock(&module_lock); + return TRITON_ERR_NOMEM; + } - triton_list_init(&triton_debug_full_masks); + triton_list_init(&triton_debug_full_masks); - ret = triton_zeroconf_register("triton.debug.file", "/dev/stderr", debug_file_updater, - "Debug file to direct all debug output"); - if(ret != TRITON_SUCCESS) - { - return ret; - } + ret = triton_zeroconf_register("triton.debug.file", "/dev/stderr", debug_file_updater, + "Debug file to direct all debug output"); + if(ret != TRITON_SUCCESS) + { + triton_zeroconf_finalize(); + triton_mutex_unlock(&module_lock); + return ret; + } - ret = triton_zeroconf_register("triton.debug.masks", "none", debug_mask_updater, - "Debug mask to enable debugging of various triton components"); - if(ret != TRITON_SUCCESS) - { - return ret; + ret = triton_zeroconf_register("triton.debug.masks", "none", debug_mask_updater, + "Debug mask to enable debugging of various triton components"); + if(ret != TRITON_SUCCESS) + { + triton_zeroconf_finalize(); + triton_mutex_unlock(&module_lock); + return ret; + } } + module_refcount++; + triton_mutex_unlock(&module_lock); return TRITON_SUCCESS; } +#if 0 static void print_masks(FILE *fp) { struct triton_debug_mask_full_entry *entry, *safe; @@ -132,30 +139,7 @@ static void print_masks(FILE *fp) entry->description ? entry->description : ""); } } - -static triton_ret_t triton_debug_init_stage2(void) -{ - char *current_masks; - - if(triton_debug_enabled_str && !strcasecmp(triton_debug_enabled_str, "show")) - { - /* output all registered masks */ - print_masks(triton_debug_fp); - return triton_error_wrap(TRITON_ERR_INVAL, TRITON_ADDR_NULL, "User requested all the debug masks"); - } - - if(!triton_debug_enabled_str) - { - return TRITON_SUCCESS; - } - - current_masks = strdup(triton_debug_enabled_str); - /* reset the current mask, since we now have all masks registered and can properly handle negated masks */ - triton_debug_enable(NULL, current_masks); - - free(current_masks); - return TRITON_SUCCESS; -} +#endif static void mask_entry_free(void *e) { @@ -164,20 +148,28 @@ static void mask_entry_free(void *e) free(entry); } -static void triton_debug_finalize(void) +void triton_debug_finalize(void) { - struct triton_debug_mask_full_entry *entry, *safe; + triton_mutex_lock(&module_lock); + module_refcount--; - triton_hash_destroy_and_finalize( - triton_debug_mask_table, struct triton_debug_mask_entry, link, mask_entry_free); - - triton_list_for_each_entry(entry, safe, &triton_debug_full_masks, struct triton_debug_mask_full_entry, link) + if(!module_refcount) { - triton_list_del(&entry->link); - if(entry->string) free(entry->string); - if(entry->description) free(entry->description); - free(entry); + struct triton_debug_mask_full_entry *entry, *safe; + + triton_hash_destroy_and_finalize( + triton_debug_mask_table, struct triton_debug_mask_entry, link, mask_entry_free); + + triton_list_for_each_entry(entry, safe, &triton_debug_full_masks, struct triton_debug_mask_full_entry, link) + { + triton_list_del(&entry->link); + if(entry->string) free(entry->string); + if(entry->description) free(entry->description); + free(entry); + } + triton_zeroconf_finalize(); } + triton_mutex_unlock(&module_lock); } static triton_ret_t triton_idebug_add_mask(int major, char *str, uint32_t *value, char *parent) @@ -660,13 +652,6 @@ triton_ret_t triton_debug_enable(const char *file, const char *masks) } } - if(!strcasecmp(masks, "show")) - { - /* don't do anything for show, handled by init_stage2 */ - triton_debug_enabled_str = strdup(masks); - return TRITON_SUCCESS; - } - if(!strcasecmp(masks, "all")) { triton_debug_enabled_none = 0; @@ -716,11 +701,6 @@ triton_ret_t triton_debug_enable(const char *file, const char *masks) } while(s); free(tmpmasks); - if(triton_debug_enabled_str) - { - free(triton_debug_enabled_str); - } - triton_debug_enabled_str = strdup(masks); return TRITON_SUCCESS; } diff --git a/code/src/common/triton-debug.h b/code/src/common/triton-debug.h index 51c7ec1..1beca11 100644 --- a/code/src/common/triton-debug.h +++ b/code/src/common/triton-debug.h @@ -18,6 +18,9 @@ typedef struct #include "src/common/triton-error.h" +void triton_debug_finalize(void); +triton_ret_t triton_debug_init(void); + /** * Add a mask to the debugging system. A debug mask is a string consisting of * '.' separated components, allowing for a hierarchy within components. diff --git a/code/src/zeroconf/zeroconf.c b/code/src/zeroconf/zeroconf.c index 483820e..922aee8 100644 --- a/code/src/zeroconf/zeroconf.c +++ b/code/src/zeroconf/zeroconf.c @@ -5,9 +5,11 @@ #include <aesop/triton-list.h> #include "src/common/triton-log.h" +static triton_mutex_t module_lock = TRITON_MUTEX_INITIALIZER; +static int module_refcount = 0; + static struct triton_hash_table *zeroconf_table = NULL; static TRITON_LIST_DEFINE(pre_init_keys); -int initialized = 0; struct zeroconf_kv { @@ -38,19 +40,25 @@ static int zc_compare(const void *key, struct triton_hash_link *link) #include "src/common/triton-init.h" #include "src/common/triton-debug.h" -static triton_ret_t triton_zeroconf_init(void) +triton_ret_t triton_zeroconf_init(void) { - zeroconf_table = triton_hash_init(zc_compare, triton_hash_strhash, 4096); - if(zeroconf_table == NULL) + triton_mutex_lock(&module_lock); + if(!module_refcount) { - return TRITON_ERR_NOMEM; + zeroconf_table = triton_hash_init(zc_compare, triton_hash_strhash, 4096); + if(zeroconf_table == NULL) + { + triton_mutex_unlock(&module_lock); + return TRITON_ERR_NOMEM; + } } - - initialized = 1; + module_refcount++; + triton_mutex_unlock(&module_lock); return TRITON_SUCCESS; } +#if 0 /* The main purpose of the stage 2 init function is to safety check that any * zeroconf parameters that were explicitly set prior to initialization * eventually got used by some component. @@ -73,6 +81,7 @@ static triton_ret_t triton_zeroconf_init_stage2(void) return(tret); } +#endif static void zc_entry_destroy(void *z) @@ -84,17 +93,16 @@ static void zc_entry_destroy(void *z) free(zce); } -static void triton_zeroconf_finalize(void) +void triton_zeroconf_finalize(void) { - triton_hash_destroy_and_finalize(zeroconf_table, struct zc_entry, link, zc_entry_destroy); - initialized = 0; -} + triton_mutex_lock(&module_lock); + module_refcount--; -__attribute__((constructor)) void triton_zeroconf_init_register(void); - -__attribute__((constructor)) void triton_zeroconf_init_register(void) -{ - triton_init_register("triton.zeroconf", triton_zeroconf_init, triton_zeroconf_finalize, triton_zeroconf_init_stage2); + if(!module_refcount) + { + triton_hash_destroy_and_finalize(zeroconf_table, struct zc_entry, link, zc_entry_destroy); + } + triton_mutex_unlock(&module_lock); } const char * triton_zeroconf_get(const char *key) @@ -118,7 +126,8 @@ triton_ret_t triton_zeroconf_set(const char *key, const char *value) struct zc_entry *zce; struct pre_init_entry* pi_entry; - if(!initialized) + triton_mutex_lock(&module_lock); + if(!module_refcount) { /* zeroconf has not been started yet; queue up this key/value pair * to be processed later @@ -126,12 +135,14 @@ triton_ret_t triton_zeroconf_set(const char *key, const char *value) pi_entry = malloc(sizeof(*pi_entry)); if(!pi_entry) { + triton_mutex_unlock(&module_lock); return(TRITON_ERR_NOMEM); } pi_entry->kv.key = strdup(key); if(!pi_entry->kv.key) { free(pi_entry); + triton_mutex_unlock(&module_lock); return(TRITON_ERR_NOMEM); } pi_entry->kv.value = strdup(value); @@ -139,12 +150,15 @@ triton_ret_t triton_zeroconf_set(const char *key, const char *value) { free(pi_entry->kv.key); free(pi_entry); + triton_mutex_unlock(&module_lock); return(TRITON_ERR_NOMEM); } triton_list_link_clear(&pi_entry->list_link); triton_list_add_back(&pi_entry->list_link, &pre_init_keys); + triton_mutex_unlock(&module_lock); return(TRITON_SUCCESS); } + triton_mutex_unlock(&module_lock); link = triton_hash_search(zeroconf_table, key); if(!link) diff --git a/code/src/zeroconf/zeroconf.h b/code/src/zeroconf/zeroconf.h index 3f4a2b7..cf035a9 100644 --- a/code/src/zeroconf/zeroconf.h +++ b/code/src/zeroconf/zeroconf.h @@ -6,6 +6,9 @@ /* TODO: make this a real zero config interface */ +triton_ret_t triton_zeroconf_init(void); +void triton_zeroconf_finalize(void); + triton_ret_t triton_zeroconf_register(const char *key, const char *init_value, triton_ret_t (*update_callback)(const char *key, const char *value), const char *info); const char * triton_zeroconf_get(const char *key); hooks/post-receive --
participants (1)
-
noreply@mcs.anl.gov