From 066c1a3c6e1354c9d3980358f5f67429df61986d Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 5 May 2015 13:45:24 +0300 Subject: [PATCH] Added a warning about multiple monitors monitoring the same servers. --- server/core/config.c | 18 +++++++++++++++++- server/include/hashtable.h | 6 +++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/server/core/config.c b/server/core/config.c index 764a606c8..4babcfdaa 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -301,7 +301,15 @@ process_config_context(CONFIG_CONTEXT *context) { CONFIG_CONTEXT *obj; int error_count = 0; +HASHTABLE* monitorhash; +if((monitorhash = hashtable_alloc(5,simple_str_hash,strcmp)) == NULL) +{ + skygw_log_write(LOGFILE_ERROR,"Error: Failed to allocate ,onitor configuration check hashtable."); + return 0; +} + +hashtable_memory_fns(monitorhash,strdup,NULL,free,NULL); /** * Process the data and create the services and servers defined * in the data. @@ -953,6 +961,13 @@ int error_count = 0; obj->element && obj1->element) { found = 1; + if(hashtable_add(monitorhash,obj1->object,"") == 0) + { + skygw_log_write(LOGFILE_ERROR, + "Warning: Multiple monitors are monitoring server [%s]. " + "This will cause undefined behavior.", + obj1->object); + } monitorAddServer( obj->element, obj1->element); @@ -1013,7 +1028,8 @@ int error_count = 0; obj = obj->next; } /*< while */ /** TODO: consistency check function */ - + + hashtable_free(monitorhash); /** * error_count += consistency_checks(); */ diff --git a/server/include/hashtable.h b/server/include/hashtable.h index a9878e3e2..26e44b799 100644 --- a/server/include/hashtable.h +++ b/server/include/hashtable.h @@ -96,7 +96,11 @@ HASHTABLE *hashtable_alloc_flat(HASHTABLE* target, int (*hashfn)(), int (*cmpfn)()); /**< Allocate a hashtable */ -extern void hashtable_memory_fns(HASHTABLE *, HASHMEMORYFN, HASHMEMORYFN, HASHMEMORYFN, HASHMEMORYFN); +extern void hashtable_memory_fns(HASHTABLE *table, + HASHMEMORYFN kcopyfn, + HASHMEMORYFN vcopyfn, + HASHMEMORYFN kfreefn, + HASHMEMORYFN vfreefn); /**< Provide an interface to control key/value memory * manipulation */