Added a warning about multiple monitors monitoring the same servers.

This commit is contained in:
Markus Makela
2015-05-05 13:45:24 +03:00
parent 6d89e156b3
commit 9c305d95c7
2 changed files with 22 additions and 2 deletions

View File

@ -301,7 +301,15 @@ process_config_context(CONFIG_CONTEXT *context)
{ {
CONFIG_CONTEXT *obj; CONFIG_CONTEXT *obj;
int error_count = 0; 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 * Process the data and create the services and servers defined
* in the data. * in the data.
@ -953,6 +961,13 @@ int error_count = 0;
obj->element && obj1->element) obj->element && obj1->element)
{ {
found = 1; 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( monitorAddServer(
obj->element, obj->element,
obj1->element); obj1->element);
@ -1014,6 +1029,7 @@ int error_count = 0;
} /*< while */ } /*< while */
/** TODO: consistency check function */ /** TODO: consistency check function */
hashtable_free(monitorhash);
/** /**
* error_count += consistency_checks(); * error_count += consistency_checks();
*/ */

View File

@ -96,7 +96,11 @@ HASHTABLE *hashtable_alloc_flat(HASHTABLE* target,
int (*hashfn)(), int (*hashfn)(),
int (*cmpfn)()); int (*cmpfn)());
/**< Allocate a hashtable */ /**< 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 /**< Provide an interface to control key/value memory
* manipulation * manipulation
*/ */