Reviewed-by: Steven Dake <sdake@xxxxxxxxxx> On 12/14/2011 08:41 AM, Jan Friesse wrote: > Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx> > --- > exec/apidef.c | 32 -- > exec/apidef.h | 3 - > exec/coroparse.c | 745 ++++++++++++++++++++++++++++++++++---- > exec/evil.c | 1 - > exec/ipc_glue.c | 294 +++++++--------- > exec/main.c | 603 +++++++------------------------ > exec/main.h | 1 - > exec/mainconfig.c | 450 +++++++----------------- > exec/mainconfig.h | 15 - > exec/objdb.c | 12 +- > exec/service.c | 398 +++++++------------- > exec/service.h | 3 +- > exec/totemconfig.c | 472 +++++++----------------- > exec/totemconfig.h | 3 - > exec/vsf_quorum.c | 52 +-- > include/corosync/engine/config.h | 6 +- > lib/sa-confdb.c | 4 +- > 17 files changed, 1361 insertions(+), 1733 deletions(-) > > diff --git a/exec/apidef.c b/exec/apidef.c > index 2d0b6cd..5d738c9 100644 > --- a/exec/apidef.c > +++ b/exec/apidef.c > @@ -151,38 +151,6 @@ static struct corosync_api_v1 apidef_corosync_api_v1 = { > .poll_dispatch_delete = cs_poll_dispatch_delete > }; > > -void apidef_init (struct objdb_iface_ver0 *objdb) { > - apidef_corosync_api_v1.object_create = objdb->object_create; > - apidef_corosync_api_v1.object_priv_set = objdb->object_priv_set; > - apidef_corosync_api_v1.object_key_create = objdb->object_key_create; > - apidef_corosync_api_v1.object_destroy = objdb->object_destroy; > - apidef_corosync_api_v1.object_valid_set = objdb->object_valid_set; > - apidef_corosync_api_v1.object_key_valid_set = objdb->object_key_valid_set; > - apidef_corosync_api_v1.object_find_create = objdb->object_find_create; > - apidef_corosync_api_v1.object_find_next = objdb->object_find_next; > - apidef_corosync_api_v1.object_find_destroy = objdb->object_find_destroy; > - apidef_corosync_api_v1.object_key_get = objdb->object_key_get; > - apidef_corosync_api_v1.object_priv_get = objdb->object_priv_get; > - apidef_corosync_api_v1.object_key_replace = objdb->object_key_replace; > - apidef_corosync_api_v1.object_key_delete = objdb->object_key_delete; > - apidef_corosync_api_v1.object_iter_reset = objdb->object_iter_reset; > - apidef_corosync_api_v1.object_iter = objdb->object_iter; > - apidef_corosync_api_v1.object_key_iter = objdb->object_key_iter; > - apidef_corosync_api_v1.object_parent_get = objdb->object_parent_get; > - apidef_corosync_api_v1.object_name_get = objdb->object_name_get; > - apidef_corosync_api_v1.object_dump = objdb->object_dump; > - apidef_corosync_api_v1.object_key_iter_from = objdb->object_key_iter_from; > - apidef_corosync_api_v1.object_track_start = objdb->object_track_start; > - apidef_corosync_api_v1.object_track_stop = objdb->object_track_stop; > - apidef_corosync_api_v1.object_write_config = objdb->object_write_config; > - apidef_corosync_api_v1.object_reload_config = objdb->object_reload_config; > - apidef_corosync_api_v1.object_key_increment = objdb->object_key_increment; > - apidef_corosync_api_v1.object_key_decrement = objdb->object_key_decrement; > - apidef_corosync_api_v1.object_key_create_typed = objdb->object_key_create_typed; > - apidef_corosync_api_v1.object_key_get_typed = objdb->object_key_get_typed; > - apidef_corosync_api_v1.object_key_iter_typed = objdb->object_key_iter_typed; > -} > - > struct corosync_api_v1 *apidef_get (void) > { > return (&apidef_corosync_api_v1); > diff --git a/exec/apidef.h b/exec/apidef.h > index 5e2a1f1..efb72ca 100644 > --- a/exec/apidef.h > +++ b/exec/apidef.h > @@ -35,11 +35,8 @@ > #ifndef APIDEF_H_DEFINED > #define APIDEF_H_DEFINED > > -#include <corosync/engine/objdb.h> > #include <corosync/engine/coroapi.h> > > -void apidef_init (struct objdb_iface_ver0 *objdb); > - > extern struct corosync_api_v1 *apidef_get (void); > > #endif /* APIDEF_H_DEFINED*/ > diff --git a/exec/coroparse.c b/exec/coroparse.c > index 302c306..e88f9cf 100644 > --- a/exec/coroparse.c > +++ b/exec/coroparse.c > @@ -1,9 +1,10 @@ > /* > - * Copyright (c) 2006, 2009 Red Hat, Inc. > + * Copyright (c) 2006, 2011 Red Hat, Inc. > * > * All rights reserved. > * > * Author: Patrick Caulfield (pcaulfie@xxxxxxxxxx) > + * Jan Friesse (jfriesse@xxxxxxxxxx) > * > * This software licensed under BSD license, the text of which follows: > * > @@ -50,37 +51,144 @@ > #include <dirent.h> > #include <limits.h> > #include <stddef.h> > +#include <grp.h> > +#include <pwd.h> > > +#include <corosync/list.h> > #include <corosync/lcr/lcr_comp.h> > -#include <corosync/engine/objdb.h> > -#include <corosync/engine/config.h> > #include <qb/qbutil.h> > #define LOGSYS_UTILS_ONLY 1 > #include <corosync/engine/logsys.h> > +#include <corosync/engine/icmap.h> > +#include <corosync/engine/config.h> > > #include "util.h" > > -static int read_config_file_into_objdb( > - struct objdb_iface_ver0 *objdb, > +enum parser_cb_type { > + PARSER_CB_START, > + PARSER_CB_END, > + PARSER_CB_SECTION_START, > + PARSER_CB_SECTION_END, > + PARSER_CB_ITEM, > +}; > + > +typedef int (*parser_cb_f)(const char *path, > + char *key, > + char *value, > + enum parser_cb_type type, > + const char **error_string, > + void *user_data); > + > +enum main_cp_cb_data_state { > + MAIN_CP_CB_DATA_STATE_NORMAL, > + MAIN_CP_CB_DATA_STATE_TOTEM, > + MAIN_CP_CB_DATA_STATE_INTERFACE, > + MAIN_CP_CB_DATA_STATE_LOGGER_SUBSYS, > + MAIN_CP_CB_DATA_STATE_UIDGID, > + MAIN_CP_CB_DATA_STATE_LOGGING_DAEMON, > + MAIN_CP_CB_DATA_STATE_MEMBER, > + MAIN_CP_CB_DATA_STATE_QUORUM, > +}; > + > +struct key_value_list_item { > + char *key; > + char *value; > + struct list_head list; > +}; > + > +struct main_cp_cb_data { > + enum main_cp_cb_data_state state; > + > + int ringnumber; > + char *bindnetaddr; > + char *mcastaddr; > + char *broadcast; > + int mcastport; > + int ttl; > + > + struct list_head logger_subsys_items_head; > + char *subsys; > + char *logging_daemon_name; > + struct list_head member_items_head; > +}; > + > +static int read_config_file_into_icmap( > const char **error_string); > static char error_string_response[512]; > > +static int uid_determine (const char *req_user) > +{ > + int pw_uid = 0; > + struct passwd passwd; > + struct passwd* pwdptr = &passwd; > + struct passwd* temp_pwd_pt; > + char *pwdbuffer; > + int pwdlinelen; > + > + pwdlinelen = sysconf (_SC_GETPW_R_SIZE_MAX); > + > + if (pwdlinelen == -1) { > + pwdlinelen = 256; > + } > + > + pwdbuffer = malloc (pwdlinelen); > > + if ((getpwnam_r (req_user, pwdptr, pwdbuffer, pwdlinelen, &temp_pwd_pt)) != 0) { > + sprintf (error_string_response, > + "The '%s' user is not found in /etc/passwd, please read the documentation.", > + req_user); > + return (-1); > + } > + pw_uid = passwd.pw_uid; > + free (pwdbuffer); > + > + return pw_uid; > +} > + > +static int gid_determine (const char *req_group) > +{ > + int ais_gid = 0; > + struct group group; > + struct group * grpptr = &group; > + struct group * temp_grp_pt; > + char *grpbuffer; > + int grplinelen; > + > + grplinelen = sysconf (_SC_GETGR_R_SIZE_MAX); > + > + if (grplinelen == -1) { > + grplinelen = 256; > + } > + > + grpbuffer = malloc (grplinelen); > + > + if ((getgrnam_r (req_group, grpptr, grpbuffer, grplinelen, &temp_grp_pt)) != 0) { > + sprintf (error_string_response, > + "The '%s' group is not found in /etc/group, please read the documentation.", > + req_group); > + return (-1); > + } > + ais_gid = group.gr_gid; > + free (grpbuffer); > + > + return ais_gid; > +} > static char *strchr_rs (const char *haystack, int byte) > { > const char *end_address = strchr (haystack, byte); > if (end_address) { > end_address += 1; /* skip past { or = */ > - end_address += strspn (end_address, " \t"); > + > + while (*end_address == ' ' || *end_address == '\t') > + end_address++; > } > > return ((char *) end_address); > } > > -static int aisparser_readconfig (struct objdb_iface_ver0 *objdb, > - const char **error_string) > +static int aisparser_readconfig (const char **error_string) > { > - if (read_config_file_into_objdb(objdb, error_string)) { > + if (read_config_file_into_icmap(error_string)) { > return -1; > } > > @@ -90,9 +198,14 @@ static int aisparser_readconfig (struct objdb_iface_ver0 *objdb, > > static char *remove_whitespace(char *string) > { > - char *start = string+strspn(string, " \t"); > - char *end = start+(strlen(start))-1; > + char *start; > + char *end; > > + start = string; > + while (*start == ' ' || *start == '\t') > + start++; > + > + end = start+(strlen(start))-1; > while ((*end == ' ' || *end == '\t' || *end == ':' || *end == '{') && end > start) > end--; > if (end != start) > @@ -101,25 +214,23 @@ static char *remove_whitespace(char *string) > return start; > } > > -#define PCHECK_ADD_SUBSECTION 1 > -#define PCHECK_ADD_ITEM 2 > > -typedef int (*parser_check_item_f)(struct objdb_iface_ver0 *objdb, > - hdb_handle_t parent_handle, > - int type, > - const char *name, > - const char **error_string); > > static int parse_section(FILE *fp, > - struct objdb_iface_ver0 *objdb, > - hdb_handle_t parent_handle, > + char *path, > const char **error_string, > - parser_check_item_f parser_check_item_call) > + parser_cb_f parser_cb, > + void *user_data) > { > char line[512]; > int i; > char *loc; > int ignore_line; > + char new_keyname[ICMAP_KEYNAME_MAXLEN]; > + > + if (strcmp(path, "") == 0) { > + parser_cb("", NULL, NULL, PARSER_CB_START, error_string, user_data); > + } > > while (fgets (line, sizeof (line), fp)) { > if (strlen(line) > 0) { > @@ -157,20 +268,22 @@ static int parse_section(FILE *fp, > > /* New section ? */ > if ((loc = strchr_rs (line, '{'))) { > - hdb_handle_t new_parent; > char *section = remove_whitespace(line); > > loc--; > *loc = '\0'; > - if (parser_check_item_call) { > - if (!parser_check_item_call(objdb, parent_handle, PCHECK_ADD_SUBSECTION, > - section, error_string)) > - return -1; > + > + strcpy(new_keyname, path); > + if (strcmp(path, "") != 0) { > + strcat(new_keyname, "."); > + } > + strcat(new_keyname, section); > + > + if (!parser_cb(new_keyname, NULL, NULL, PARSER_CB_SECTION_START, error_string, user_data)) { > + return -1; > } > > - objdb->object_create (parent_handle, &new_parent, > - section, strlen (section)); > - if (parse_section(fp, objdb, new_parent, error_string, parser_check_item_call)) > + if (parse_section(fp, new_keyname, error_string, parser_cb, user_data)) > return -1; > } > > @@ -182,59 +295,552 @@ static int parse_section(FILE *fp, > *(loc-1) = '\0'; > key = remove_whitespace(line); > value = remove_whitespace(loc); > - if (parser_check_item_call) { > - if (!parser_check_item_call(objdb, parent_handle, PCHECK_ADD_ITEM, > - key, error_string)) > - return -1; > + > + strcpy(new_keyname, path); > + if (strcmp(path, "") != 0) { > + strcat(new_keyname, "."); > + } > + strcat(new_keyname, key); > + > + if (!parser_cb(new_keyname, key, value, PARSER_CB_ITEM, error_string, user_data)) { > + return -1; > } > - objdb->object_key_create_typed (parent_handle, key, > - value, strlen (value) + 1, OBJDB_VALUETYPE_STRING); > } > > if (strchr_rs (line, '}')) { > + if (!parser_cb(path, NULL, NULL, PARSER_CB_SECTION_END, error_string, user_data)) { > + return -1; > + } > + > return 0; > } > } > > - if (parent_handle != OBJECT_PARENT_HANDLE) { > + if (strcmp(path, "") != 0) { > *error_string = "Missing closing brace"; > return -1; > } > > + if (strcmp(path, "") == 0) { > + parser_cb("", NULL, NULL, PARSER_CB_END, error_string, user_data); > + } > + > return 0; > } > > -static int parser_check_item_uidgid(struct objdb_iface_ver0 *objdb, > - hdb_handle_t parent_handle, > - int type, > - const char *name, > - const char **error_string) > +static int main_config_parser_cb(const char *path, > + char *key, > + char *value, > + enum parser_cb_type type, > + const char **error_string, > + void *user_data) > { > - if (type == PCHECK_ADD_SUBSECTION) { > - if (parent_handle != OBJECT_PARENT_HANDLE) { > - *error_string = "uidgid: Can't add second level subsection"; > - return 0; > + int i; > + int add_as_string; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > + struct main_cp_cb_data *data = (struct main_cp_cb_data *)user_data; > + struct key_value_list_item *kv_item; > + struct list_head *iter, *iter_next; > + int uid, gid; > + > + switch (type) { > + case PARSER_CB_START: > + memset(data, 0, sizeof(struct main_cp_cb_data)); > + data->state = MAIN_CP_CB_DATA_STATE_NORMAL; > + break; > + case PARSER_CB_END: > + break; > + case PARSER_CB_ITEM: > + add_as_string = 1; > + > + switch (data->state) { > + case MAIN_CP_CB_DATA_STATE_NORMAL: > + break; > + case MAIN_CP_CB_DATA_STATE_QUORUM: > + if ((strcmp(path, "quorum.expected_votes") == 0) || > + (strcmp(path, "quorum.votes") == 0) || > + (strcmp(path, "quorum.quorumdev_poll") == 0) || > + (strcmp(path, "quorum.leaving_timeout") == 0)) { > + i = atoi(value); > + icmap_set_uint32(path, i); > + add_as_string = 0; > + } > + > + if ((strcmp(path, "quorum.disallowed") == 0) || > + (strcmp(path, "quorum.two_node") == 0) || > + (strcmp(path, "quorum.quorate") == 0)) { > + i = atoi(value); > + icmap_set_uint8(path, i); > + add_as_string = 0; > + } > + break; > + case MAIN_CP_CB_DATA_STATE_TOTEM: > + if ((strcmp(path, "totem.version") == 0) || > + (strcmp(path, "totem.nodeid") == 0) || > + (strcmp(path, "totem.threads") == 0) || > + (strcmp(path, "totem.token") == 0) || > + (strcmp(path, "totem.token_retransmit") == 0) || > + (strcmp(path, "totem.hold") == 0) || > + (strcmp(path, "totem.token_retransmits_before_loss_const") == 0) || > + (strcmp(path, "totem.join") == 0) || > + (strcmp(path, "totem.send_join") == 0) || > + (strcmp(path, "totem.consensus") == 0) || > + (strcmp(path, "totem.merge") == 0) || > + (strcmp(path, "totem.downcheck") == 0) || > + (strcmp(path, "totem.fail_recv_const") == 0) || > + (strcmp(path, "totem.seqno_unchanged_const") == 0) || > + (strcmp(path, "totem.rrp_token_expired_timeout") == 0) || > + (strcmp(path, "totem.rrp_problem_count_timeout") == 0) || > + (strcmp(path, "totem.rrp_problem_count_threshold") == 0) || > + (strcmp(path, "totem.rrp_problem_count_mcast_threshold") == 0) || > + (strcmp(path, "totem.rrp_autorecovery_check_timeout") == 0) || > + (strcmp(path, "totem.heartbeat_failures_allowed") == 0) || > + (strcmp(path, "totem.max_network_delay") == 0) || > + (strcmp(path, "totem.window_size") == 0) || > + (strcmp(path, "totem.max_messages") == 0) || > + (strcmp(path, "totem.miss_count_const") == 0) || > + (strcmp(path, "totem.netmtu") == 0)) { > + i = atoi(value); > + icmap_set_uint32(path, i); > + add_as_string = 0; > + } > + case MAIN_CP_CB_DATA_STATE_INTERFACE: > + if (strcmp(path, "totem.interface.ringnumber") == 0) { > + data->ringnumber = atoi(value); > + add_as_string = 0; > + } > + if (strcmp(path, "totem.interface.bindnetaddr") == 0) { > + data->bindnetaddr = strdup(value); > + add_as_string = 0; > + } > + if (strcmp(path, "totem.interface.mcastaddr") == 0) { > + data->mcastaddr = strdup(value); > + add_as_string = 0; > + } > + if (strcmp(path, "totem.interface.broadcast") == 0) { > + data->broadcast = strdup(value); > + add_as_string = 0; > + } > + if (strcmp(path, "totem.interface.mcastport") == 0) { > + data->mcastport = atoi(value); > + if (data->mcastport < 0 || data->mcastport > 65535) { > + *error_string = "Invalid multicast port (should be 0..65535)"; > + > + return (0); > + }; > + add_as_string = 0; > + } > + if (strcmp(path, "totem.interface.ttl") == 0) { > + data->ttl = atoi(value); > + if (data->ttl < 0 || data->ttl > 255) { > + *error_string = "Invalid TTL (should be 0..255)"; > + > + return (0); > + }; > + add_as_string = 0; > + } > + break; > + case MAIN_CP_CB_DATA_STATE_LOGGER_SUBSYS: > + if (strcmp(key, "subsys") == 0) { > + data->subsys = strdup(value); > + if (data->subsys == NULL) { > + *error_string = "Can't alloc memory"; > + > + return (0); > + } > + } else { > + kv_item = malloc(sizeof(*kv_item)); > + if (kv_item == NULL) { > + *error_string = "Can't alloc memory"; > + > + return (0); > + } > + memset(kv_item, 0, sizeof(*kv_item)); > + > + kv_item->key = strdup(key); > + kv_item->value = strdup(value); > + if (kv_item->key == NULL || kv_item->value == NULL) { > + free(kv_item); > + *error_string = "Can't alloc memory"; > + > + return (0); > + } > + list_init(&kv_item->list); > + list_add(&kv_item->list, &data->logger_subsys_items_head); > + } > + add_as_string = 0; > + break; > + case MAIN_CP_CB_DATA_STATE_LOGGING_DAEMON: > + if (strcmp(key, "subsys") == 0) { > + data->subsys = strdup(value); > + if (data->subsys == NULL) { > + *error_string = "Can't alloc memory"; > + > + return (0); > + } > + } else if (strcmp(key, "name") == 0) { > + data->logging_daemon_name = strdup(value); > + if (data->logging_daemon_name == NULL) { > + *error_string = "Can't alloc memory"; > + > + return (0); > + } > + } else { > + kv_item = malloc(sizeof(*kv_item)); > + if (kv_item == NULL) { > + *error_string = "Can't alloc memory"; > + > + return (0); > + } > + memset(kv_item, 0, sizeof(*kv_item)); > + > + kv_item->key = strdup(key); > + kv_item->value = strdup(value); > + if (kv_item->key == NULL || kv_item->value == NULL) { > + free(kv_item); > + *error_string = "Can't alloc memory"; > + > + return (0); > + } > + list_init(&kv_item->list); > + list_add(&kv_item->list, &data->logger_subsys_items_head); > + } > + add_as_string = 0; > + break; > + case MAIN_CP_CB_DATA_STATE_UIDGID: > + if (strcmp(key, "uid") == 0) { > + uid = uid_determine(value); > + if (uid == -1) { > + *error_string = error_string_response; > + return (0); > + } > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "uidgid.uid.%u", > + uid); > + icmap_set_uint8(key_name, 1); > + add_as_string = 0; > + } else if (strcmp(key, "gid") == 0) { > + gid = gid_determine(value); > + if (gid == -1) { > + *error_string = error_string_response; > + return (0); > + } > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "uidgid.gid.%u", > + gid); > + icmap_set_uint8(key_name, 1); > + add_as_string = 0; > + } else { > + *error_string = "uidgid: Only uid and gid are allowed items"; > + return (0); > + } > + break; > + case MAIN_CP_CB_DATA_STATE_MEMBER: > + if (strcmp(key, "memberaddr") != 0) { > + *error_string = "Only memberaddr is allowed in member section"; > + > + return (0); > + } > + > + kv_item = malloc(sizeof(*kv_item)); > + if (kv_item == NULL) { > + *error_string = "Can't alloc memory"; > + > + return (0); > + } > + memset(kv_item, 0, sizeof(*kv_item)); > + > + kv_item->key = strdup(key); > + kv_item->value = strdup(value); > + if (kv_item->key == NULL || kv_item->value == NULL) { > + free(kv_item); > + *error_string = "Can't alloc memory"; > + > + return (0); > + } > + list_init(&kv_item->list); > + list_add(&kv_item->list, &data->member_items_head); > + add_as_string = 0; > + break; > } > > - if (strcmp (name, "uidgid") != 0) { > - *error_string = "uidgid: Can't add subsection different then uidgid"; > - return 0; > + if (add_as_string) { > + icmap_set_string(path, value); > + } > + break; > + case PARSER_CB_SECTION_START: > + if (strcmp(path, "totem.interface") == 0) { > + data->state = MAIN_CP_CB_DATA_STATE_INTERFACE; > + data->ringnumber = 0; > + data->mcastport = -1; > + data->ttl = -1; > + list_init(&data->member_items_head); > + }; > + if (strcmp(path, "totem") == 0) { > + data->state = MAIN_CP_CB_DATA_STATE_TOTEM; > + }; > + > + if (strcmp(path, "logging.logger_subsys") == 0) { > + data->state = MAIN_CP_CB_DATA_STATE_LOGGER_SUBSYS; > + list_init(&data->logger_subsys_items_head); > + data->subsys = NULL; > + } > + if (strcmp(path, "logging.logging_daemon") == 0) { > + data->state = MAIN_CP_CB_DATA_STATE_LOGGING_DAEMON; > + list_init(&data->logger_subsys_items_head); > + data->subsys = NULL; > + data->logging_daemon_name = NULL; > + } > + if (strcmp(path, "uidgid") == 0) { > + data->state = MAIN_CP_CB_DATA_STATE_UIDGID; > + } > + if (strcmp(path, "totem.interface.member") == 0) { > + data->state = MAIN_CP_CB_DATA_STATE_MEMBER; > + } > + if (strcmp(path, "quorum") == 0) { > + data->state = MAIN_CP_CB_DATA_STATE_QUORUM; > + } > + break; > + case PARSER_CB_SECTION_END: > + switch (data->state) { > + case MAIN_CP_CB_DATA_STATE_NORMAL: > + break; > + case MAIN_CP_CB_DATA_STATE_INTERFACE: > + /* > + * Create new interface section > + */ > + if (data->bindnetaddr != NULL) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.bindnetaddr", > + data->ringnumber); > + icmap_set_string(key_name, data->bindnetaddr); > + > + free(data->bindnetaddr); > + data->bindnetaddr = NULL; > + } else { > + *error_string = "No bindnetaddr for interface"; > + > + return (0); > + } > + > + if (data->mcastaddr != NULL) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastaddr", > + data->ringnumber); > + icmap_set_string(key_name, data->mcastaddr); > + > + free(data->mcastaddr); > + data->mcastaddr = NULL; > + } > + > + if (data->broadcast != NULL) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.broadcast", > + data->ringnumber); > + icmap_set_string(key_name, data->broadcast); > + > + free(data->broadcast); > + data->broadcast = NULL; > + } > + > + if (data->mcastport > -1) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastport", > + data->ringnumber); > + icmap_set_uint16(key_name, data->mcastport); > + } > + > + if (data->ttl > -1) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.ttl", > + data->ringnumber); > + icmap_set_uint8(key_name, data->ttl); > + } > + > + i = 0; > + for (iter = data->member_items_head.next; > + iter != &data->member_items_head; iter = iter_next) { > + kv_item = list_entry(iter, struct key_value_list_item, list); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.member.%u", > + data->ringnumber, i); > + icmap_set_string(key_name, kv_item->value); > + > + iter_next = iter->next; > + > + free(kv_item->value); > + free(kv_item->key); > + free(kv_item); > + i++; > + } > + > + data->state = MAIN_CP_CB_DATA_STATE_TOTEM; > + break; > + case MAIN_CP_CB_DATA_STATE_TOTEM: > + data->state = MAIN_CP_CB_DATA_STATE_NORMAL; > + break; > + case MAIN_CP_CB_DATA_STATE_LOGGER_SUBSYS: > + if (data->subsys == NULL) { > + *error_string = "No subsys key in logger_subsys directive"; > + > + return (0); > + } > + > + for (iter = data->logger_subsys_items_head.next; > + iter != &data->logger_subsys_items_head; iter = iter_next) { > + kv_item = list_entry(iter, struct key_value_list_item, list); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "logging.logger_subsys.%s.%s", > + data->subsys, kv_item->key); > + icmap_set_string(key_name, kv_item->value); > + > + iter_next = iter->next; > + > + free(kv_item->value); > + free(kv_item->key); > + free(kv_item); > + } > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "logging.logger_subsys.%s.subsys", > + data->subsys); > + icmap_set_string(key_name, data->subsys); > + > + free(data->subsys); > + > + data->state = MAIN_CP_CB_DATA_STATE_NORMAL; > + break; > + case MAIN_CP_CB_DATA_STATE_LOGGING_DAEMON: > + if (data->logging_daemon_name == NULL) { > + *error_string = "No name key in logging_daemon directive"; > + > + return (0); > + } > + > + for (iter = data->logger_subsys_items_head.next; > + iter != &data->logger_subsys_items_head; iter = iter_next) { > + kv_item = list_entry(iter, struct key_value_list_item, list); > + > + if (data->subsys == NULL) { > + if (strcmp(data->logging_daemon_name, "corosync") == 0) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, > + "logging.%s", > + kv_item->key); > + } else { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, > + "logging.logging_daemon.%s.%s", > + data->logging_daemon_name, kv_item->key); > + } > + } else { > + if (strcmp(data->logging_daemon_name, "corosync") == 0) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, > + "logging.logger_subsys.%s.%s", > + data->subsys, > + kv_item->key); > + } else { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, > + "logging.logging_daemon.%s.%s.%s", > + data->logging_daemon_name, data->subsys, > + kv_item->key); > + } > + } > + icmap_set_string(key_name, kv_item->value); > + > + iter_next = iter->next; > + > + free(kv_item->value); > + free(kv_item->key); > + free(kv_item); > + } > + > + if (data->subsys == NULL) { > + if (strcmp(data->logging_daemon_name, "corosync") != 0) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "logging.logging_daemon.%s.name", > + data->logging_daemon_name); > + icmap_set_string(key_name, data->logging_daemon_name); > + } > + } else { > + if (strcmp(data->logging_daemon_name, "corosync") == 0) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "logging.logger_subsys.%s.subsys", > + data->subsys); > + icmap_set_string(key_name, data->subsys); > + > + } else { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "logging.logging_daemon.%s.%s.subsys", > + data->logging_daemon_name, data->subsys); > + icmap_set_string(key_name, data->subsys); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "logging.logging_daemon.%s.%s.name", > + data->logging_daemon_name, data->subsys); > + icmap_set_string(key_name, data->logging_daemon_name); > + } > + } > + > + free(data->subsys); > + free(data->logging_daemon_name); > + > + data->state = MAIN_CP_CB_DATA_STATE_NORMAL; > + break; > + case MAIN_CP_CB_DATA_STATE_UIDGID: > + data->state = MAIN_CP_CB_DATA_STATE_UIDGID; > + break; > + case MAIN_CP_CB_DATA_STATE_MEMBER: > + data->state = MAIN_CP_CB_DATA_STATE_INTERFACE; > + break; > + case MAIN_CP_CB_DATA_STATE_QUORUM: > + data->state = MAIN_CP_CB_DATA_STATE_NORMAL; > + break; > } > + break; > } > > - if (type == PCHECK_ADD_ITEM) { > - if (!(strcmp (name, "uid") == 0 || strcmp (name, "gid") == 0)) { > + return (1); > +} > + > +static int uidgid_config_parser_cb(const char *path, > + char *key, > + char *value, > + enum parser_cb_type type, > + const char **error_string, > + void *user_data) > +{ > + char key_name[ICMAP_KEYNAME_MAXLEN]; > + int uid, gid; > + > + switch (type) { > + case PARSER_CB_START: > + break; > + case PARSER_CB_END: > + break; > + case PARSER_CB_ITEM: > + if (strcmp(path, "uidgid.uid") == 0) { > + uid = uid_determine(value); > + if (uid == -1) { > + *error_string = error_string_response; > + return (0); > + } > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "uidgid.uid.%u", > + uid); > + icmap_set_uint8(key_name, 1); > + } else if (strcmp(key, "uidgid.gid") == 0) { > + gid = gid_determine(value); > + if (gid == -1) { > + *error_string = error_string_response; > + return (0); > + } > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "uidgid.gid.%u", > + gid); > + icmap_set_uint8(key_name, 1); > + } else { > *error_string = "uidgid: Only uid and gid are allowed items"; > - return 0; > + return (0); > } > + break; > + case PARSER_CB_SECTION_START: > + if (strcmp(path, "uidgid") != 0) { > + *error_string = "uidgid: Can't add subsection different then uidgid"; > + return (0); > + }; > + break; > + case PARSER_CB_SECTION_END: > + break; > } > > - return 1; > + return (1); > } > > - > -static int read_uidgid_files_into_objdb( > - struct objdb_iface_ver0 *objdb, > +static int read_uidgid_files_into_icmap( > const char **error_string) > { > FILE *fp; > @@ -247,6 +853,7 @@ static int read_uidgid_files_into_objdb( > size_t len; > int return_code; > struct stat stat_buf; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > > dirname = COROSYSCONFDIR "/uidgid.d"; > dp = opendir (dirname); > @@ -273,7 +880,9 @@ static int read_uidgid_files_into_objdb( > fp = fopen (filename, "r"); > if (fp == NULL) continue; > > - res = parse_section(fp, objdb, OBJECT_PARENT_HANDLE, error_string, parser_check_item_uidgid); > + key_name[0] = 0; > + > + res = parse_section(fp, key_name, error_string, uidgid_config_parser_cb, NULL); > > fclose (fp); > > @@ -290,8 +899,7 @@ error_exit: > return res; > } > > -static int read_service_files_into_objdb( > - struct objdb_iface_ver0 *objdb, > +static int read_service_files_into_icmap( > const char **error_string) > { > FILE *fp; > @@ -304,6 +912,8 @@ static int read_service_files_into_objdb( > struct stat stat_buf; > size_t len; > int return_code; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > + struct main_cp_cb_data data; > > dirname = COROSYSCONFDIR "/service.d"; > dp = opendir (dirname); > @@ -330,7 +940,9 @@ static int read_service_files_into_objdb( > fp = fopen (filename, "r"); > if (fp == NULL) continue; > > - res = parse_section(fp, objdb, OBJECT_PARENT_HANDLE, error_string, NULL); > + key_name[0] = 0; > + > + res = parse_section(fp, key_name, error_string, main_config_parser_cb, &data); > > fclose (fp); > > @@ -347,15 +959,16 @@ error_exit: > return res; > } > > -/* Read config file and load into objdb */ > -static int read_config_file_into_objdb( > - struct objdb_iface_ver0 *objdb, > +/* Read config file and load into icmap */ > +static int read_config_file_into_icmap( > const char **error_string) > { > FILE *fp; > const char *filename; > char *error_reason = error_string_response; > int res; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > + struct main_cp_cb_data data; > > filename = getenv ("COROSYNC_MAIN_CONFIG_FILE"); > if (!filename) > @@ -372,16 +985,18 @@ static int read_config_file_into_objdb( > return -1; > } > > - res = parse_section(fp, objdb, OBJECT_PARENT_HANDLE, error_string, NULL); > + key_name[0] = 0; > + > + res = parse_section(fp, key_name, error_string, main_config_parser_cb, &data); > > fclose(fp); > > if (res == 0) { > - res = read_uidgid_files_into_objdb(objdb, error_string); > + res = read_uidgid_files_into_icmap(error_string); > } > > if (res == 0) { > - res = read_service_files_into_objdb(objdb, error_string); > + res = read_service_files_into_icmap(error_string); > } > > if (res == 0) { > diff --git a/exec/evil.c b/exec/evil.c > index 9ad8a21..94db799 100644 > --- a/exec/evil.c > +++ b/exec/evil.c > @@ -70,7 +70,6 @@ > #include <corosync/corodefs.h> > #include <corosync/list.h> > #include <corosync/lcr/lcr_ifact.h> > -#include <corosync/engine/objdb.h> > #include <corosync/engine/config.h> > #include <corosync/engine/coroapi.h> > #include <corosync/engine/logsys.h> > diff --git a/exec/ipc_glue.c b/exec/ipc_glue.c > index 8ec7c96..6dadcd5 100644 > --- a/exec/ipc_glue.c > +++ b/exec/ipc_glue.c > @@ -51,9 +51,8 @@ > #include <corosync/corotypes.h> > #include <corosync/corodefs.h> > #include <corosync/totem/totempg.h> > -#include <corosync/engine/objdb.h> > -#include <corosync/engine/config.h> > #include <corosync/engine/logsys.h> > +#include <corosync/engine/icmap.h> > > #include "mainconfig.h" > #include "sync.h" > @@ -71,7 +70,6 @@ static int32_t ipc_not_enough_fds_left = 0; > static int32_t ipc_fc_is_quorate; /* boolean */ > static int32_t ipc_fc_totem_queue_level; /* percentage used */ > static int32_t ipc_fc_sync_in_process; /* boolean */ > -static qb_handle_t object_connection_handle; > > struct cs_ipcs_mapper { > int32_t id; > @@ -187,6 +185,9 @@ static const char* cs_ipcs_serv_short_name(int32_t service_id) > case WD_SERVICE: > name = "wd"; > break; > + case CMAP_SERVICE: > + name = "cmap"; > + break; > default: > name = NULL; > break; > @@ -205,8 +206,9 @@ int32_t cs_ipcs_service_destroy(int32_t service_id) > > static int32_t cs_ipcs_connection_accept (qb_ipcs_connection_t *c, uid_t euid, gid_t egid) > { > - struct list_head *iter; > int32_t service = qb_ipcs_service_id_get(c); > + uint8_t u8; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > > if (ais_service[service] == NULL || > ais_service_exiting[service] || > @@ -222,15 +224,14 @@ static int32_t cs_ipcs_connection_accept (qb_ipcs_connection_t *c, uid_t euid, g > return 0; > } > > - for (iter = uidgid_list_head.next; iter != &uidgid_list_head; > - iter = iter->next) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "uidgid.uid.%u", euid); > + if (icmap_get_uint8(key_name, &u8) == CS_OK && u8 == 1) > + return 0; > > - struct uidgid_item *ugi = qb_list_entry (iter, struct uidgid_item, > - list); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "uidgid.gid.%u", egid); > + if (icmap_get_uint8(key_name, &u8) == CS_OK && u8 == 1) > + return 0; > > - if (euid == ugi->uid || egid == ugi->gid) > - return 0; > - } > log_printf(LOGSYS_LEVEL_ERROR, "Denied connection attempt from %d:%d", euid, egid); > > return -EACCES; > @@ -280,9 +281,8 @@ static char * pid_to_name (pid_t pid, char *out_name, size_t name_len) > return out_name; > } > > - > struct cs_ipcs_conn_context { > - qb_handle_t stats_handle; > + char *icmap_path; > struct list_head outq_head; > int32_t queuing; > uint32_t queued; > @@ -295,15 +295,13 @@ struct cs_ipcs_conn_context { > static void cs_ipcs_connection_created(qb_ipcs_connection_t *c) > { > int32_t service = 0; > - uint32_t zero_32 = 0; > - uint64_t zero_64 = 0; > - unsigned int key_incr_dummy; > - qb_handle_t object_handle; > struct cs_ipcs_conn_context *context; > - char conn_name[42]; > char proc_name[32]; > struct qb_ipcs_connection_stats stats; > int32_t size = sizeof(struct cs_ipcs_conn_context); > + char key_name[ICMAP_KEYNAME_MAXLEN]; > + int set_client_pid = 0; > + int set_proc_name = 0; > > log_printf(LOG_INFO, "%s() new connection", __func__); > > @@ -321,95 +319,75 @@ static void cs_ipcs_connection_created(qb_ipcs_connection_t *c) > > ais_service[service]->lib_init_fn(c); > > - api->object_key_increment (object_connection_handle, > - "active", strlen("active"), > - &key_incr_dummy); > + icmap_inc("runtime.connections.active"); > > qb_ipcs_connection_stats_get(c, &stats, QB_FALSE); > > if (stats.client_pid > 0) { > if (pid_to_name (stats.client_pid, proc_name, sizeof(proc_name))) { > - snprintf (conn_name, > - sizeof(conn_name), > - "%s:%d:%p", proc_name, > - stats.client_pid, c); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "runtime.connections.%s:%u:%p", > + proc_name, stats.client_pid, c); > + set_proc_name = 1; > } else { > - snprintf (conn_name, > - sizeof(conn_name), > - "%d:%p", > - stats.client_pid, c); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "runtime.connections.%u:%p", > + stats.client_pid, c); > } > + set_client_pid = 1; > } else { > - snprintf (conn_name, > - sizeof(conn_name), > - "%p", c); > - } > - > - api->object_create (object_connection_handle, > - &object_handle, > - conn_name, > - strlen (conn_name)); > - context->stats_handle = object_handle; > - > - api->object_key_create_typed (object_handle, > - "service_id", > - &zero_32, sizeof (zero_32), > - OBJDB_VALUETYPE_UINT32); > - > - api->object_key_create_typed (object_handle, > - "client_pid", > - &zero_32, sizeof (zero_32), > - OBJDB_VALUETYPE_INT32); > - > - api->object_key_create_typed (object_handle, > - "responses", > - &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > - > - api->object_key_create_typed (object_handle, > - "dispatched", > - &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > - > - api->object_key_create_typed (object_handle, > - "requests", > - &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_INT64); > - > - api->object_key_create_typed (object_handle, > - "send_retries", > - &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > - > - api->object_key_create_typed (object_handle, > - "recv_retries", > - &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > - > - api->object_key_create_typed (object_handle, > - "flow_control", > - &zero_32, sizeof (zero_32), > - OBJDB_VALUETYPE_UINT32); > - > - api->object_key_create_typed (object_handle, > - "flow_control_count", > - &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > - > - api->object_key_create_typed (object_handle, > - "queue_size", > - &zero_32, sizeof (zero_32), > - OBJDB_VALUETYPE_UINT32); > - > - api->object_key_create_typed (object_handle, > - "invalid_request", > - &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > - > - api->object_key_create_typed (object_handle, > - "overload", > - &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "runtime.connections.%p", c); > + } > + > + icmap_convert_name_to_valid_name(key_name); > + > + context->icmap_path = strdup(key_name); > + if (context->icmap_path == NULL) { > + return ; > + } > + > + if (set_proc_name) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.name", context->icmap_path); > + icmap_set_string(key_name, proc_name); > + } > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.client_pid", context->icmap_path); > + if (set_client_pid) { > + icmap_set_uint32(key_name, stats.client_pid); > + } else { > + icmap_set_uint32(key_name, 0); > + } > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.service_id", context->icmap_path); > + icmap_set_uint32(key_name, service); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.responses", context->icmap_path); > + icmap_set_uint64(key_name, 0); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.dispatched", context->icmap_path); > + icmap_set_uint64(key_name, 0); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.requests", context->icmap_path); > + icmap_set_uint64(key_name, 0); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.send_retries", context->icmap_path); > + icmap_set_uint64(key_name, 0); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.recv_retries", context->icmap_path); > + icmap_set_uint64(key_name, 0); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.flow_control", context->icmap_path); > + icmap_set_uint32(key_name, 0); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.flow_control_count", context->icmap_path); > + icmap_set_uint64(key_name, 0); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.queue_size", context->icmap_path); > + icmap_set_uint32(key_name, 0); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.invalid_request", context->icmap_path); > + icmap_set_uint64(key_name, 0); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.overload", context->icmap_path); > + icmap_set_uint64(key_name, 0); > } > > void cs_ipc_refcnt_inc(void *conn) > @@ -455,10 +433,12 @@ static void cs_ipcs_connection_destroyed (qb_ipcs_connection_t *c) > > static int32_t cs_ipcs_connection_closed (qb_ipcs_connection_t *c) > { > - struct cs_ipcs_conn_context *cnx; > - unsigned int key_incr_dummy; > int32_t res = 0; > int32_t service = qb_ipcs_service_id_get(c); > + icmap_iter_t iter; > + char prefix[ICMAP_KEYNAME_MAXLEN]; > + const char *key_name; > + struct cs_ipcs_conn_context *cnx; > > log_printf(LOG_INFO, "%s() ", __func__); > res = ais_service[service]->lib_exit_fn(c); > @@ -467,14 +447,16 @@ static int32_t cs_ipcs_connection_closed (qb_ipcs_connection_t *c) > } > > cnx = qb_ipcs_context_get(c); > - api->object_destroy (cnx->stats_handle); > > - api->object_key_increment (object_connection_handle, > - "closed", strlen("closed"), > - &key_incr_dummy); > - api->object_key_decrement (object_connection_handle, > - "active", strlen("active"), > - &key_incr_dummy); > + snprintf(prefix, ICMAP_KEYNAME_MAXLEN, "%s.", cnx->icmap_path); > + iter = icmap_iter_init(prefix); > + while ((key_name = icmap_iter_next(iter, NULL, NULL)) != NULL) { > + icmap_delete(key_name); > + } > + free(cnx->icmap_path); > + > + icmap_inc("runtie.connections.closed"); > + icmap_dec("runtime.connections.active"); > > return 0; > } > @@ -787,6 +769,7 @@ void cs_ipcs_stats_update(void) > struct qb_ipcs_connection_stats stats; > qb_ipcs_connection_t *c; > struct cs_ipcs_conn_context *cnx; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > > for (i = 0; i < SERVICE_HANDLER_MAXIMUM_COUNT; i++) { > if (ais_service[i] == NULL || ipcs_mapper[i].inst == NULL) { > @@ -802,40 +785,39 @@ void cs_ipcs_stats_update(void) > > qb_ipcs_connection_stats_get(c, &stats, QB_FALSE); > > - api->object_key_replace(cnx->stats_handle, > - "client_pid", strlen("client_pid"), > - &stats.client_pid, sizeof(uint32_t)); > - > - api->object_key_replace(cnx->stats_handle, > - "requests", strlen("requests"), > - &stats.requests, sizeof(uint64_t)); > - api->object_key_replace(cnx->stats_handle, > - "responses", strlen("responses"), > - &stats.responses, sizeof(uint64_t)); > - api->object_key_replace(cnx->stats_handle, > - "dispatched", strlen("dispatched"), > - &stats.events, sizeof(uint64_t)); > - api->object_key_replace(cnx->stats_handle, > - "send_retries", strlen("send_retries"), > - &stats.send_retries, sizeof(uint64_t)); > - api->object_key_replace(cnx->stats_handle, > - "recv_retries", strlen("recv_retries"), > - &stats.recv_retries, sizeof(uint64_t)); > - api->object_key_replace(cnx->stats_handle, > - "flow_control", strlen("flow_control"), > - &stats.flow_control_state, sizeof(uint32_t)); > - api->object_key_replace(cnx->stats_handle, > - "flow_control_count", strlen("flow_control_count"), > - &stats.flow_control_count, sizeof(uint64_t)); > - api->object_key_replace(cnx->stats_handle, > - "queue_size", strlen("queue_size"), > - &cnx->queued, sizeof(uint32_t)); > - api->object_key_replace(cnx->stats_handle, > - "invalid_request", strlen("invalid_request"), > - &cnx->invalid_request, sizeof(uint64_t)); > - api->object_key_replace(cnx->stats_handle, > - "overload", strlen("overload"), > - &cnx->overload, sizeof(uint64_t)); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.client_pid", cnx->icmap_path); > + icmap_set_uint32(key_name, stats.client_pid); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.requests", cnx->icmap_path); > + icmap_set_uint64(key_name, stats.requests); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.responses", cnx->icmap_path); > + icmap_set_uint64(key_name, stats.responses); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.dispatched", cnx->icmap_path); > + icmap_set_uint64(key_name, stats.events); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.send_retries", cnx->icmap_path); > + icmap_set_uint64(key_name, stats.send_retries); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.recv_retries", cnx->icmap_path); > + icmap_set_uint64(key_name, stats.recv_retries); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.flow_control", cnx->icmap_path); > + icmap_set_uint32(key_name, stats.flow_control_state); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.flow_control_count", cnx->icmap_path); > + icmap_set_uint64(key_name, stats.flow_control_count); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.queue_size", cnx->icmap_path); > + icmap_set_uint32(key_name, cnx->queued); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.invalid_request", cnx->icmap_path); > + icmap_set_uint64(key_name, cnx->invalid_request); > + > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.overload", cnx->icmap_path); > + icmap_set_uint64(key_name, cnx->overload); > + > qb_ipcs_connection_unref(c); > } > } > @@ -868,10 +850,6 @@ void cs_ipcs_service_init(struct corosync_service_engine *service) > > void cs_ipcs_init(void) > { > - qb_handle_t object_find_handle; > - qb_handle_t object_runtime_handle; > - uint64_t zero_64 = 0; > - > api = apidef_get (); > > qb_loop_poll_low_fds_event_set(cs_poll_handle_get(), cs_ipcs_low_fds_event); > @@ -879,27 +857,9 @@ void cs_ipcs_init(void) > api->quorum_register_callback (cs_ipcs_fc_quorum_changed, NULL); > totempg_queue_level_register_callback (cs_ipcs_totem_queue_level_changed); > > - api->object_find_create (OBJECT_PARENT_HANDLE, > - "runtime", strlen ("runtime"), > - &object_find_handle); > - > - if (api->object_find_next (object_find_handle, > - &object_runtime_handle) != 0) { > - log_printf (LOGSYS_LEVEL_ERROR,"arrg no runtime"); > - return; > - } > - > - /* Connection objects */ > - api->object_create (object_runtime_handle, > - &object_connection_handle, > - "connections", strlen ("connections")); > + icmap_set_ro_access("runtime.connections.", 1, 1); > > - api->object_key_create_typed (object_connection_handle, > - "active", &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > - api->object_key_create_typed (object_connection_handle, > - "closed", &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > - api->object_find_destroy (object_find_handle); > + icmap_set_uint64("runtime.connections.active", 0); > + icmap_set_uint64("runtime.connections.closed", 0); > } > > diff --git a/exec/main.c b/exec/main.c > index 0e3954a..019f659 100644 > --- a/exec/main.c > +++ b/exec/main.c > @@ -107,9 +107,9 @@ > #include <corosync/list.h> > #include <corosync/lcr/lcr_ifact.h> > #include <corosync/totem/totempg.h> > -#include <corosync/engine/objdb.h> > #include <corosync/engine/config.h> > #include <corosync/engine/logsys.h> > +#include <corosync/engine/icmap.h> > > #include "quorum.h" > #include "totemsrp.h" > @@ -150,8 +150,6 @@ static int num_config_modules; > > static struct config_iface_ver0 *config_modules[MAX_DYNAMIC_SERVICES]; > > -static struct objdb_iface_ver0 *objdb = NULL; > - > static struct corosync_api_v1 *api = NULL; > > static enum cs_sync_mode minimum_sync_mode; > @@ -162,8 +160,6 @@ static qb_loop_t *corosync_poll_handle; > > struct sched_param global_sched_param; > > -static hdb_handle_t object_memb_handle; > - > static corosync_timer_handle_t corosync_stats_timer_handle; > > static const char *corosync_lock_file = LOCALSTATEDIR"/run/corosync.pid"; > @@ -344,75 +340,30 @@ static struct memb_ring_id corosync_ring_id; > > static void member_object_joined (unsigned int nodeid) > { > - hdb_handle_t object_find_handle; > - hdb_handle_t object_node_handle; > - char * nodeint_str; > - char nodeid_str[64]; > - unsigned int key_incr_dummy; > - > - snprintf (nodeid_str, 64, "%d", nodeid); > - > - objdb->object_find_create ( > - object_memb_handle, > - nodeid_str, > - strlen (nodeid_str), > - &object_find_handle); > - > - if (objdb->object_find_next (object_find_handle, > - &object_node_handle) == 0) { > - > - objdb->object_key_increment (object_node_handle, > - "join_count", strlen("join_count"), > - &key_incr_dummy); > - > - objdb->object_key_replace (object_node_handle, > - "status", strlen("status"), > - "joined", strlen("joined")); > + char member_ip[ICMAP_KEYNAME_MAXLEN]; > + char member_join_count[ICMAP_KEYNAME_MAXLEN]; > + char member_status[ICMAP_KEYNAME_MAXLEN]; > + > + snprintf(member_ip, ICMAP_KEYNAME_MAXLEN, "runtime.totem.pg.mrp.srp.members.%u.ip", nodeid); > + snprintf(member_join_count, ICMAP_KEYNAME_MAXLEN, "runtime.totem.pg.mrp.srp.members.%u.join_count", nodeid); > + snprintf(member_status, ICMAP_KEYNAME_MAXLEN, "runtime.totem.pg.mrp.srp.members.%u.status", nodeid); > + > + if (icmap_get(member_ip, NULL, NULL, NULL) == CS_OK) { > + icmap_inc(member_join_count); > + icmap_set_string(member_status, "joined"); > } else { > - nodeint_str = (char*)api->totem_ifaces_print (nodeid); > - objdb->object_create (object_memb_handle, > - &object_node_handle, > - nodeid_str, strlen (nodeid_str)); > - > - objdb->object_key_create_typed (object_node_handle, > - "ip", > - nodeint_str, strlen(nodeint_str), > - OBJDB_VALUETYPE_STRING); > - key_incr_dummy = 1; > - objdb->object_key_create_typed (object_node_handle, > - "join_count", > - &key_incr_dummy, sizeof (key_incr_dummy), > - OBJDB_VALUETYPE_UINT32); > - objdb->object_key_create_typed (object_node_handle, > - "status", > - "joined", strlen("joined"), > - OBJDB_VALUETYPE_STRING); > - } > - objdb->object_find_destroy (object_find_handle); > + icmap_set_string(member_ip, (char*)api->totem_ifaces_print (nodeid)); > + icmap_set_uint32(member_join_count, 1); > + icmap_set_string(member_status, "joined"); > + } > } > > static void member_object_left (unsigned int nodeid) > { > - hdb_handle_t object_find_handle; > - hdb_handle_t object_node_handle; > - char nodeid_str[64]; > - > - snprintf (nodeid_str, 64, "%u", nodeid); > - > - objdb->object_find_create ( > - object_memb_handle, > - nodeid_str, > - strlen (nodeid_str), > - &object_find_handle); > - > - if (objdb->object_find_next (object_find_handle, > - &object_node_handle) == 0) { > + char member_status[ICMAP_KEYNAME_MAXLEN]; > > - objdb->object_key_replace (object_node_handle, > - "status", strlen("status"), > - "left", strlen("left")); > - } > - objdb->object_find_destroy (object_find_handle); > + snprintf(member_status, ICMAP_KEYNAME_MAXLEN, "runtime.totem.pg.mrp.srp.members.%u.status", nodeid); > + icmap_set_string(member_status, "left"); > } > > static void confchg_fn ( > @@ -541,102 +492,42 @@ static void corosync_mlockall (void) > static void corosync_totem_stats_updater (void *data) > { > totempg_stats_t * stats; > - uint32_t mtt_rx_token; > uint32_t total_mtt_rx_token; > - uint32_t avg_backlog_calc; > uint32_t total_backlog_calc; > - uint32_t avg_token_holdtime; > uint32_t total_token_holdtime; > int t, prev; > int32_t token_count; > - uint32_t firewall_enabled_or_nic_failure; > > stats = api->totem_get_stats(); > > - objdb->object_key_replace (stats->hdr.handle, > - "msg_reserved", strlen("msg_reserved"), > - &stats->msg_reserved, sizeof (stats->msg_reserved)); > - objdb->object_key_replace (stats->hdr.handle, > - "msg_queue_avail", strlen("msg_queue_avail"), > - &stats->msg_queue_avail, sizeof (stats->msg_queue_avail)); > - > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "orf_token_tx", strlen("orf_token_tx"), > - &stats->mrp->srp->orf_token_tx, sizeof (stats->mrp->srp->orf_token_tx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "orf_token_rx", strlen("orf_token_rx"), > - &stats->mrp->srp->orf_token_rx, sizeof (stats->mrp->srp->orf_token_rx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "memb_merge_detect_tx", strlen("memb_merge_detect_tx"), > - &stats->mrp->srp->memb_merge_detect_tx, sizeof (stats->mrp->srp->memb_merge_detect_tx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "memb_merge_detect_rx", strlen("memb_merge_detect_rx"), > - &stats->mrp->srp->memb_merge_detect_rx, sizeof (stats->mrp->srp->memb_merge_detect_rx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "memb_join_tx", strlen("memb_join_tx"), > - &stats->mrp->srp->memb_join_tx, sizeof (stats->mrp->srp->memb_join_tx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "memb_join_rx", strlen("memb_join_rx"), > - &stats->mrp->srp->memb_join_rx, sizeof (stats->mrp->srp->memb_join_rx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "mcast_tx", strlen("mcast_tx"), > - &stats->mrp->srp->mcast_tx, sizeof (stats->mrp->srp->mcast_tx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "mcast_retx", strlen("mcast_retx"), > - &stats->mrp->srp->mcast_retx, sizeof (stats->mrp->srp->mcast_retx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "mcast_rx", strlen("mcast_rx"), > - &stats->mrp->srp->mcast_rx, sizeof (stats->mrp->srp->mcast_rx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "memb_commit_token_tx", strlen("memb_commit_token_tx"), > - &stats->mrp->srp->memb_commit_token_tx, sizeof (stats->mrp->srp->memb_commit_token_tx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "memb_commit_token_rx", strlen("memb_commit_token_rx"), > - &stats->mrp->srp->memb_commit_token_rx, sizeof (stats->mrp->srp->memb_commit_token_rx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "token_hold_cancel_tx", strlen("token_hold_cancel_tx"), > - &stats->mrp->srp->token_hold_cancel_tx, sizeof (stats->mrp->srp->token_hold_cancel_tx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "token_hold_cancel_rx", strlen("token_hold_cancel_rx"), > - &stats->mrp->srp->token_hold_cancel_rx, sizeof (stats->mrp->srp->token_hold_cancel_rx)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "operational_entered", strlen("operational_entered"), > - &stats->mrp->srp->operational_entered, sizeof (stats->mrp->srp->operational_entered)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "operational_token_lost", strlen("operational_token_lost"), > - &stats->mrp->srp->operational_token_lost, sizeof (stats->mrp->srp->operational_token_lost)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "gather_entered", strlen("gather_entered"), > - &stats->mrp->srp->gather_entered, sizeof (stats->mrp->srp->gather_entered)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "gather_token_lost", strlen("gather_token_lost"), > - &stats->mrp->srp->gather_token_lost, sizeof (stats->mrp->srp->gather_token_lost)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "commit_entered", strlen("commit_entered"), > - &stats->mrp->srp->commit_entered, sizeof (stats->mrp->srp->commit_entered)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "commit_token_lost", strlen("commit_token_lost"), > - &stats->mrp->srp->commit_token_lost, sizeof (stats->mrp->srp->commit_token_lost)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "recovery_entered", strlen("recovery_entered"), > - &stats->mrp->srp->recovery_entered, sizeof (stats->mrp->srp->recovery_entered)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "recovery_token_lost", strlen("recovery_token_lost"), > - &stats->mrp->srp->recovery_token_lost, sizeof (stats->mrp->srp->recovery_token_lost)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "consensus_timeouts", strlen("consensus_timeouts"), > - &stats->mrp->srp->consensus_timeouts, sizeof (stats->mrp->srp->consensus_timeouts)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "rx_msg_dropped", strlen("rx_msg_dropped"), > - &stats->mrp->srp->rx_msg_dropped, sizeof (stats->mrp->srp->rx_msg_dropped)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "continuous_gather", strlen("continuous_gather"), > - &stats->mrp->srp->continuous_gather, sizeof (stats->mrp->srp->continuous_gather)); > - > - firewall_enabled_or_nic_failure = (stats->mrp->srp->continuous_gather > MAX_NO_CONT_GATHER ? 1 : 0); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "firewall_enabled_or_nic_failure", strlen("firewall_enabled_or_nic_failure"), > - &firewall_enabled_or_nic_failure, sizeof (firewall_enabled_or_nic_failure)); > + icmap_set_uint32("runtime.totem.pg.msg_reserved", stats->msg_reserved); > + icmap_set_uint32("runtime.totem.pg.msg_queue_avail", stats->msg_queue_avail); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.orf_token_tx", stats->mrp->srp->orf_token_tx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.orf_token_rx", stats->mrp->srp->orf_token_rx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.memb_merge_detect_tx", stats->mrp->srp->memb_merge_detect_tx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.memb_merge_detect_rx", stats->mrp->srp->memb_merge_detect_rx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.memb_join_tx", stats->mrp->srp->memb_join_tx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.memb_join_rx", stats->mrp->srp->memb_join_rx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.mcast_tx", stats->mrp->srp->mcast_tx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.mcast_retx", stats->mrp->srp->mcast_retx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.mcast_rx", stats->mrp->srp->mcast_rx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.memb_commit_token_tx", stats->mrp->srp->memb_commit_token_tx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.memb_commit_token_rx", stats->mrp->srp->memb_commit_token_rx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.token_hold_cancel_tx", stats->mrp->srp->token_hold_cancel_tx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.token_hold_cancel_rx", stats->mrp->srp->token_hold_cancel_rx); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.operational_entered", stats->mrp->srp->operational_entered); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.operational_token_lost", stats->mrp->srp->operational_token_lost); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.gather_entered", stats->mrp->srp->gather_entered); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.gather_token_lost", stats->mrp->srp->gather_token_lost); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.commit_entered", stats->mrp->srp->commit_entered); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.commit_token_lost", stats->mrp->srp->commit_token_lost); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.recovery_entered", stats->mrp->srp->recovery_entered); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.recovery_token_lost", stats->mrp->srp->recovery_token_lost); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.consensus_timeouts", stats->mrp->srp->consensus_timeouts); > + icmap_set_uint64("runtime.totem.pg.mrp.srp.rx_msg_dropped", stats->mrp->srp->rx_msg_dropped); > + icmap_set_uint32("runtime.totem.pg.mrp.srp.continuous_gather", stats->mrp->srp->continuous_gather); > + icmap_set_uint8("runtime.totem.pg.mrp.srp.firewall_enabled_or_nic_failure", > + stats->mrp->srp->continuous_gather > MAX_NO_CONT_GATHER ? 1 : 0); > > total_mtt_rx_token = 0; > total_token_holdtime = 0; > @@ -661,18 +552,9 @@ static void corosync_totem_stats_updater (void *data) > t = prev; > } > if (token_count) { > - mtt_rx_token = (total_mtt_rx_token / token_count); > - avg_backlog_calc = (total_backlog_calc / token_count); > - avg_token_holdtime = (total_token_holdtime / token_count); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "mtt_rx_token", strlen("mtt_rx_token"), > - &mtt_rx_token, sizeof (mtt_rx_token)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "avg_token_workload", strlen("avg_token_workload"), > - &avg_token_holdtime, sizeof (avg_token_holdtime)); > - objdb->object_key_replace (stats->mrp->srp->hdr.handle, > - "avg_backlog_calc", strlen("avg_backlog_calc"), > - &avg_backlog_calc, sizeof (avg_backlog_calc)); > + icmap_set_uint32("runtime.totem.pg.mrp.srp.mtt_rx_token", (total_mtt_rx_token / token_count)); > + icmap_set_uint32("runtime.totem.pg.mrp.srp.avg_token_workload", (total_token_holdtime / token_count)); > + icmap_set_uint32("runtime.totem.pg.mrp.srp.avg_backlog_calc", (total_backlog_calc / token_count)); > } > > cs_ipcs_stats_update(); > @@ -682,262 +564,82 @@ static void corosync_totem_stats_updater (void *data) > &corosync_stats_timer_handle); > } > > -static void totem_dynamic_name_to_ip (char *dest, > - size_t dest_size, > - const void *src, > - size_t src_len) > -{ > - char *p; > - size_t len; > - > - len = (src_len + 1 > dest_size) ? dest_size-1 : src_len; > - memset(dest, 0, dest_size); > - memcpy(dest, src, len); > - for (p = dest; p != dest + len; p++) { > - if (*p == '-') { > - *p = '.'; > - } > - } > -} > - > -static void totem_dynamic_create_notify_fn ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *name_pt, size_t name_len, > - void *priv_data_pt) > +static void totem_dynamic_notify( > + int32_t event, > + const char *key_name, > + struct icmap_notify_value new_val, > + struct icmap_notify_value old_val, > + void *user_data) > { > + int res; > + int ring_no; > + int member_no; > struct totem_ip_address member; > - int ring_no; > - char object_name[128]; > + int add_new_member = 0; > + int remove_old_member = 0; > > - totem_dynamic_name_to_ip (object_name, > - sizeof object_name, name_pt, name_len); > - log_printf (LOGSYS_LEVEL_DEBUG, > - "adding dynamic member: %s\n", object_name); > + res = sscanf(key_name, "totem.interface.%u.member.%u", &ring_no, &member_no); > + if (res != 2) > + return ; > > - /* > - * add new member > - */ > - if (totemip_parse (&member, object_name, 0) == 0) { > - ring_no = 0; > - totempg_member_add (&member, ring_no); > + if (event == ICMAP_TRACK_ADD && new_val.type == ICMAP_VALUETYPE_STRING) { > + add_new_member = 1; > } > -} > - > -static void totem_dynamic_destroy_notify_fn( > - hdb_handle_t parent_object_handle, > - const void *name_pt, size_t name_len, > - void *priv_data_pt) > -{ > - struct totem_ip_address member; > - int ring_no; > - char object_name[128]; > - > - totem_dynamic_name_to_ip (object_name, sizeof object_name, > - name_pt, name_len); > - log_printf(LOGSYS_LEVEL_DEBUG, > - "removing dynamic member: %s\n", object_name); > > - /* > - * remove member > - */ > - if (totemip_parse(&member, object_name, 0) == 0) { > - ring_no = 0; > - totempg_member_remove (&member, ring_no); > + if (event == ICMAP_TRACK_DELETE && old_val.type == ICMAP_VALUETYPE_STRING) { > + remove_old_member = 1; > } > -} > > -static void corosync_totem_dynamic_init (void) > -{ > - hdb_handle_t object_find_handle; > - hdb_handle_t object_totem_handle; > - hdb_handle_t object_interface_handle; > - hdb_handle_t object_dynamic_handle; > - > - if (objdb->object_find_create (OBJECT_PARENT_HANDLE, > - "totem", strlen("totem"), &object_find_handle) != 0) { > - log_printf(LOGSYS_LEVEL_ERROR, > - "corosync_totem_dynamic_init:: FAILED to find totem!\n"); > - return; > - } > - if (objdb->object_find_next (object_find_handle, > - &object_totem_handle) != 0) { > - return; > + if (event == ICMAP_TRACK_MODIFY && new_val.type == ICMAP_VALUETYPE_STRING && > + old_val.type == ICMAP_VALUETYPE_STRING) { > + add_new_member = 1; > + remove_old_member = 1; > } > - api->object_find_destroy (object_find_handle); > - > - if (objdb->object_find_create(object_totem_handle, > - "interface", strlen("interface"), &object_find_handle) != 0) { > > - log_printf(LOGSYS_LEVEL_ERROR, > - "corosync_totem_dynamic_init:: FAILED to find totem.interface!\n"); > - return; > + if (remove_old_member) { > + log_printf(LOGSYS_LEVEL_DEBUG, > + "removing dynamic member %s for ring %u\n", (char *)old_val.data, ring_no); > + if (totemip_parse(&member, (char *)old_val.data, 0) == 0) { > + totempg_member_remove (&member, ring_no); > + } > } > - if (objdb->object_find_next (object_find_handle, > - &object_interface_handle) != 0) { > > - return; > + if (add_new_member) { > + log_printf(LOGSYS_LEVEL_DEBUG, > + "adding dynamic member %s for ring %u\n", (char *)new_val.data, ring_no); > + if (totemip_parse(&member, (char *)new_val.data, 0) == 0) { > + totempg_member_add (&member, ring_no); > + } > } > - api->object_find_destroy (object_find_handle); > - > - /* > - * create new child object: dynamic > - */ > - if (objdb->object_create (object_interface_handle, > - &object_dynamic_handle, > - "dynamic", strlen("dynamic")) != 0) { > +} > > - log_printf(LOGSYS_LEVEL_ERROR, > - "unable to create object: \"totem.interface.dynamic\"\n"); > - return; > - } > +static void corosync_totem_dynamic_init (void) > +{ > + icmap_track_t icmap_track; > > - objdb->object_track_start (object_dynamic_handle, > - OBJECT_TRACK_DEPTH_RECURSIVE, > + icmap_track_add("totem.interface.", > + ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY | ICMAP_TRACK_PREFIX, > + totem_dynamic_notify, > NULL, > - totem_dynamic_create_notify_fn, > - totem_dynamic_destroy_notify_fn, > - NULL, NULL); > + &icmap_track); > } > > static void corosync_totem_stats_init (void) > { > totempg_stats_t * stats; > - hdb_handle_t object_find_handle; > - hdb_handle_t object_runtime_handle; > - hdb_handle_t object_totem_handle; > - uint32_t zero_32 = 0; > - uint64_t zero_64 = 0; > > stats = api->totem_get_stats(); > > - objdb->object_find_create ( > - OBJECT_PARENT_HANDLE, > - "runtime", > - strlen ("runtime"), > - &object_find_handle); > - > - if (objdb->object_find_next (object_find_handle, > - &object_runtime_handle) == 0) { > - > - objdb->object_create (object_runtime_handle, > - &object_totem_handle, > - "totem", strlen ("totem")); > - objdb->object_create (object_totem_handle, > - &stats->hdr.handle, > - "pg", strlen ("pg")); > - objdb->object_create (stats->hdr.handle, > - &stats->mrp->hdr.handle, > - "mrp", strlen ("mrp")); > - objdb->object_create (stats->mrp->hdr.handle, > - &stats->mrp->srp->hdr.handle, > - "srp", strlen ("srp")); > - > - objdb->object_key_create_typed (stats->hdr.handle, > - "msg_reserved", &stats->msg_reserved, > - sizeof (stats->msg_reserved), OBJDB_VALUETYPE_UINT32); > - objdb->object_key_create_typed (stats->hdr.handle, > - "msg_queue_avail", &stats->msg_queue_avail, > - sizeof (stats->msg_queue_avail), OBJDB_VALUETYPE_UINT32); > - > - /* Members object */ > - objdb->object_create (stats->mrp->srp->hdr.handle, > - &object_memb_handle, > - "members", strlen ("members")); > - > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "orf_token_tx", &stats->mrp->srp->orf_token_tx, > - sizeof (stats->mrp->srp->orf_token_tx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "orf_token_rx", &stats->mrp->srp->orf_token_rx, > - sizeof (stats->mrp->srp->orf_token_rx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "memb_merge_detect_tx", &stats->mrp->srp->memb_merge_detect_tx, > - sizeof (stats->mrp->srp->memb_merge_detect_tx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "memb_merge_detect_rx", &stats->mrp->srp->memb_merge_detect_rx, > - sizeof (stats->mrp->srp->memb_merge_detect_rx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "memb_join_tx", &stats->mrp->srp->memb_join_tx, > - sizeof (stats->mrp->srp->memb_join_tx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "memb_join_rx", &stats->mrp->srp->memb_join_rx, > - sizeof (stats->mrp->srp->memb_join_rx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "mcast_tx", &stats->mrp->srp->mcast_tx, > - sizeof (stats->mrp->srp->mcast_tx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "mcast_retx", &stats->mrp->srp->mcast_retx, > - sizeof (stats->mrp->srp->mcast_retx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "mcast_rx", &stats->mrp->srp->mcast_rx, > - sizeof (stats->mrp->srp->mcast_rx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "memb_commit_token_tx", &stats->mrp->srp->memb_commit_token_tx, > - sizeof (stats->mrp->srp->memb_commit_token_tx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "memb_commit_token_rx", &stats->mrp->srp->memb_commit_token_rx, > - sizeof (stats->mrp->srp->memb_commit_token_rx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "token_hold_cancel_tx", &stats->mrp->srp->token_hold_cancel_tx, > - sizeof (stats->mrp->srp->token_hold_cancel_tx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "token_hold_cancel_rx", &stats->mrp->srp->token_hold_cancel_rx, > - sizeof (stats->mrp->srp->token_hold_cancel_rx), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "operational_entered", &stats->mrp->srp->operational_entered, > - sizeof (stats->mrp->srp->operational_entered), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "operational_token_lost", &stats->mrp->srp->operational_token_lost, > - sizeof (stats->mrp->srp->operational_token_lost), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "gather_entered", &stats->mrp->srp->gather_entered, > - sizeof (stats->mrp->srp->gather_entered), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "gather_token_lost", &stats->mrp->srp->gather_token_lost, > - sizeof (stats->mrp->srp->gather_token_lost), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "commit_entered", &stats->mrp->srp->commit_entered, > - sizeof (stats->mrp->srp->commit_entered), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "commit_token_lost", &stats->mrp->srp->commit_token_lost, > - sizeof (stats->mrp->srp->commit_token_lost), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "recovery_entered", &stats->mrp->srp->recovery_entered, > - sizeof (stats->mrp->srp->recovery_entered), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "recovery_token_lost", &stats->mrp->srp->recovery_token_lost, > - sizeof (stats->mrp->srp->recovery_token_lost), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "consensus_timeouts", &stats->mrp->srp->consensus_timeouts, > - sizeof (stats->mrp->srp->consensus_timeouts), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "mtt_rx_token", &zero_32, > - sizeof (zero_32), OBJDB_VALUETYPE_UINT32); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "avg_token_workload", &zero_32, > - sizeof (zero_32), OBJDB_VALUETYPE_UINT32); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "avg_backlog_calc", &zero_32, > - sizeof (zero_32), OBJDB_VALUETYPE_UINT32); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "rx_msg_dropped", &zero_64, > - sizeof (zero_64), OBJDB_VALUETYPE_UINT64); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "continuous_gather", &zero_32, > - sizeof (zero_32), OBJDB_VALUETYPE_UINT32); > - objdb->object_key_create_typed (stats->mrp->srp->hdr.handle, > - "firewall_enabled_or_nic_failure", &zero_32, > - sizeof (zero_32), OBJDB_VALUETYPE_UINT32); > - > - } > - objdb->object_find_destroy (object_find_handle); > + icmap_set_uint32("runtime.totem.pg.mrp.srp.mtt_rx_token", 0); > + icmap_set_uint32("runtime.totem.pg.mrp.srp.avg_token_workload", 0); > + icmap_set_uint32("runtime.totem.pg.mrp.srp.avg_backlog_calc", 0); > + > + icmap_set_ro_access("runtime.totem", CS_TRUE, CS_TRUE); > > /* start stats timer */ > api->timer_add_duration (1500 * MILLI_2_NANO_SECONDS, NULL, > corosync_totem_stats_updater, > &corosync_stats_timer_handle); > - > } > > > @@ -951,7 +653,6 @@ static void deliver_fn ( > int32_t service; > int32_t fn_id; > uint32_t id; > - uint32_t key_incr_dummy; > > header = msg; > if (endian_conversion_required) { > @@ -980,9 +681,7 @@ static void deliver_fn ( > return; > } > > - objdb->object_key_increment (service_stats_handle[service][fn_id], > - "rx", strlen("rx"), > - &key_incr_dummy); > + icmap_inc(service_stats_rx[service][fn_id]); > > if (endian_conversion_required) { > assert(ais_service[service]->exec_engine[fn_id].exec_endian_convert_fn != NULL); > @@ -1008,14 +707,12 @@ int main_mcast ( > const struct qb_ipc_request_header *req = iovec->iov_base; > int32_t service; > int32_t fn_id; > - uint32_t key_incr_dummy; > > service = req->id >> 16; > fn_id = req->id & 0xffff; > > if (ais_service[service]) { > - objdb->object_key_increment (service_stats_handle[service][fn_id], > - "tx", strlen("tx"), &key_incr_dummy); > + icmap_inc(service_stats_tx[service][fn_id]); > } > > return (totempg_groups_mcast_joined (corosync_group_handle, iovec, iov_len, guarantee)); > @@ -1182,55 +879,37 @@ _logsys_log_printf(int level, int subsys, > } > > static void fplay_key_change_notify_fn ( > - object_change_type_t change_type, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *object_name_pt, size_t object_name_len, > - const void *key_name_pt, size_t key_len, > - const void *key_value_pt, size_t key_value_len, > - void *priv_data_pt) > + int32_t event, > + const char *key_name, > + struct icmap_notify_value new_val, > + struct icmap_notify_value old_val, > + void *user_data) > { > - if (key_len == strlen ("dump_flight_data") && > - memcmp ("dump_flight_data", key_name_pt, key_len) == 0) { > + if (strcmp(key_name, "runtime.blackbox.dump_flight_data") == 0) { > + fprintf(stderr,"Writetofile\n"); > qb_log_blackbox_write_to_file (LOCALSTATEDIR "/lib/corosync/fdata"); > } > - if (key_len == strlen ("dump_state") && > - memcmp ("dump_state", key_name_pt, key_len) == 0) { > + if (strcmp(key_name, "runtime.blackbox.dump_state") == 0) { > + fprintf(stderr,"statefump\n"); > corosync_state_dump (); > } > } > > static void corosync_fplay_control_init (void) > { > - hdb_handle_t object_find_handle; > - hdb_handle_t object_runtime_handle; > - hdb_handle_t object_blackbox_handle; > - > - objdb->object_find_create (OBJECT_PARENT_HANDLE, > - "runtime", strlen ("runtime"), > - &object_find_handle); > - > - if (objdb->object_find_next (object_find_handle, > - &object_runtime_handle) != 0) { > - return; > - } > - objdb->object_find_destroy (object_find_handle); > - > - objdb->object_create (object_runtime_handle, > - &object_blackbox_handle, > - "blackbox", strlen ("blackbox")); > - > - objdb->object_key_create_typed (object_blackbox_handle, > - "dump_flight_data", "no", strlen("no"), > - OBJDB_VALUETYPE_STRING); > - objdb->object_key_create_typed (object_blackbox_handle, > - "dump_state", "no", strlen("no"), > - OBJDB_VALUETYPE_STRING); > - > - objdb->object_track_start (object_blackbox_handle, > - OBJECT_TRACK_DEPTH_RECURSIVE, > - fplay_key_change_notify_fn, > - NULL, NULL, NULL, NULL); > + icmap_track_t track; > + > + icmap_set_string("runtime.blackbox.dump_flight_data", "no"); > + icmap_set_string("runtime.blackbox.dump_state", "no"); > + > + icmap_track_add("runtime.blackbox.dump_flight_data", > + ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY, > + fplay_key_change_notify_fn, > + NULL, &track); > + icmap_track_add("runtime.blackbox.dump_state", > + ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY, > + fplay_key_change_notify_fn, > + NULL, &track); > } > > static void main_service_ready (void) > @@ -1363,10 +1042,8 @@ int main (int argc, char **argv, char **envp) > { > const char *error_string; > struct totem_config totem_config; > - hdb_handle_t objdb_handle; > hdb_handle_t config_handle; > unsigned int config_version = 0; > - void *objdb_p; > struct config_iface_ver0 *config; > void *config_p; > const char *config_iface_init; > @@ -1377,7 +1054,6 @@ int main (int argc, char **argv, char **envp) > int background, setprio; > struct stat stat_out; > char corosync_lib_dir[PATH_MAX]; > - hdb_handle_t object_runtime_handle; > enum e_ais_done flock_err; > > /* default configuration > @@ -1444,28 +1120,14 @@ int main (int argc, char **argv, char **envp) > (void)signal (SIGPIPE, SIG_IGN); > #endif > > - /* > - * Load the object database interface > - */ > - res = lcr_ifact_reference ( > - &objdb_handle, > - "objdb", > - 0, > - &objdb_p, > - 0); > - if (res == -1) { > - log_printf (LOGSYS_LEVEL_ERROR, "Corosync Executive couldn't open configuration object database component.\n"); > + if (icmap_init() != CS_OK) { > + log_printf (LOGSYS_LEVEL_ERROR, "Corosync Executive couldn't initialize configuration component.\n"); > corosync_exit_error (AIS_DONE_OBJDB); > } > > - objdb = (struct objdb_iface_ver0 *)objdb_p; > - > - objdb->objdb_init (); > - > /* > * Initialize the corosync_api_v1 definition > */ > - apidef_init (objdb); > api = apidef_get (); > > num_config_modules = 0; > @@ -1502,7 +1164,7 @@ int main (int argc, char **argv, char **envp) > corosync_exit_error (AIS_DONE_MAINCONFIGREAD); > } > > - res = config->config_readconfig(objdb, &error_string); > + res = config->config_readconfig(&error_string); > if (res == -1) { > log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string); > corosync_exit_error (AIS_DONE_MAINCONFIGREAD); > @@ -1514,7 +1176,7 @@ int main (int argc, char **argv, char **envp) > } > free(config_iface); > > - res = corosync_main_config_read (objdb, &error_string); > + res = corosync_main_config_read (&error_string); > if (res == -1) { > /* > * if we are here, we _must_ flush the logsys queue > @@ -1539,13 +1201,13 @@ int main (int argc, char **argv, char **envp) > corosync_exit_error (AIS_DONE_DIR_NOT_PRESENT); > } > > - res = totem_config_read (objdb, &totem_config, &error_string); > + res = totem_config_read (&totem_config, &error_string); > if (res == -1) { > log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string); > corosync_exit_error (AIS_DONE_MAINCONFIGREAD); > } > > - res = totem_config_keyread (objdb, &totem_config, &error_string); > + res = totem_config_keyread (&totem_config, &error_string); > if (res == -1) { > log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string); > corosync_exit_error (AIS_DONE_MAINCONFIGREAD); > @@ -1567,19 +1229,13 @@ int main (int argc, char **argv, char **envp) > totem_config.totem_logging_configuration.log_printf = _logsys_log_printf; > logsys_config_apply(); > > - res = corosync_main_config_compatibility_read (objdb, > - &minimum_sync_mode, > + res = corosync_main_config_compatibility_read (&minimum_sync_mode, > &error_string); > if (res == -1) { > log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string); > corosync_exit_error (AIS_DONE_MAINCONFIGREAD); > } > > - /* create the main runtime object */ > - objdb->object_create (OBJECT_PARENT_HANDLE, > - &object_runtime_handle, > - "runtime", strlen ("runtime")); > - > /* > * Now we are fully initialized. > */ > @@ -1649,9 +1305,8 @@ int main (int argc, char **argv, char **envp) > qb_loop_destroy (corosync_poll_handle); > > /* > - * free up the objdb > + * free up the icmap > */ > - objdb->objdb_fini (); > > /* > * Remove pid lock file > diff --git a/exec/main.h b/exec/main.h > index 2efedef..91a2706 100644 > --- a/exec/main.h > +++ b/exec/main.h > @@ -48,7 +48,6 @@ > #include <corosync/hdb.h> > #include <qb/qbloop.h> > #include <corosync/totem/totempg.h> > -#include <corosync/engine/objdb.h> > #include <corosync/engine/config.h> > #include <corosync/engine/coroapi.h> > > diff --git a/exec/mainconfig.c b/exec/mainconfig.c > index 8a6787f..1c0d4a9 100644 > --- a/exec/mainconfig.c > +++ b/exec/mainconfig.c > @@ -1,10 +1,11 @@ > /* > * Copyright (c) 2002-2005 MontaVista Software, Inc. > - * Copyright (c) 2006-2009 Red Hat, Inc. > + * Copyright (c) 2006-2011 Red Hat, Inc. > * > * All rights reserved. > * > * Author: Steven Dake (sdake@xxxxxxxxxx) > + * Jan Friesse (jfriesse@xxxxxxxxxx) > * > * This software licensed under BSD license, the text of which follows: > * > @@ -43,66 +44,19 @@ > #include <sys/socket.h> > #include <netinet/in.h> > #include <arpa/inet.h> > -#include <pwd.h> > -#include <grp.h> > #include <limits.h> > > #include <corosync/corotypes.h> > #include <corosync/list.h> > #include <corosync/totem/totem.h> > #include <corosync/engine/logsys.h> > +#include <corosync/engine/icmap.h> > > #include "util.h" > #include "mainconfig.h" > > static char error_string_response[512]; > > -static struct objdb_iface_ver0 *global_objdb; > - > -DECLARE_LIST_INIT(uidgid_list_head); > - > - > -/* This just makes the code below a little neater */ > -static inline int objdb_get_string ( > - const struct objdb_iface_ver0 *objdb, > - hdb_handle_t object_service_handle, > - const char *key, char **value) > -{ > - int res; > - > - *value = NULL; > - if ( !(res = objdb->object_key_get (object_service_handle, > - key, > - strlen (key), > - (void *)value, > - NULL))) { > - > - if (*value) { > - return 0; > - } > - } > - return -1; > -} > - > -static inline void objdb_get_int ( > - const struct objdb_iface_ver0 *objdb, > - hdb_handle_t object_service_handle, > - char *key, unsigned int *intvalue) > -{ > - char *value = NULL; > - > - if (!objdb->object_key_get (object_service_handle, > - key, > - strlen (key), > - (void *)&value, > - NULL)) { > - > - if (value) { > - *intvalue = atoi(value); > - } > - } > -} > - > /** > * insert_into_buffer > * @target_buffer: a buffer where to write results > @@ -179,16 +133,14 @@ static int insert_into_buffer( > * doesn't apply at system/subsystem level. > */ > static int corosync_main_config_format_set ( > - struct objdb_iface_ver0 *objdb, > - hdb_handle_t object_handle, > const char **error_string) > { > const char *error_reason; > char new_format_buffer[PATH_MAX]; > - char *value; > - int err = 0; > + char *value = NULL; > + cs_error_t err; > > - if (!objdb_get_string (objdb,object_handle, "fileline", &value)) { > + if (icmap_get_string("logging.fileline", &value) == CS_OK) { > if (strcmp (value, "on") == 0) { > if (!insert_into_buffer(new_format_buffer, > sizeof(new_format_buffer), > @@ -207,8 +159,11 @@ static int corosync_main_config_format_set ( > error_reason = "unknown value for fileline"; > goto parse_error; > } > + > + free(value); > } > - if (!objdb_get_string (objdb,object_handle, "function_name", &value)) { > + > + if (icmap_get_string("logging.function_name", &value) == CS_OK) { > if (strcmp (value, "on") == 0) { > if (!insert_into_buffer(new_format_buffer, > sizeof(new_format_buffer), > @@ -227,8 +182,11 @@ static int corosync_main_config_format_set ( > error_reason = "unknown value for function_name"; > goto parse_error; > } > + > + free(value); > } > - if (!objdb_get_string (objdb,object_handle, "timestamp", &value)) { > + > + if (icmap_get_string("logging.timestamp", &value) == CS_OK) { > if (strcmp (value, "on") == 0) { > if(!insert_into_buffer(new_format_buffer, > sizeof(new_format_buffer), > @@ -242,40 +200,40 @@ static int corosync_main_config_format_set ( > error_reason = "unknown value for timestamp"; > goto parse_error; > } > - } > - if (err) { > - error_reason = "exhausted virtual memory"; > - goto parse_error; > + > + free(value); > } > > return (0); > > parse_error: > + free(value); > *error_string = error_reason; > > return (-1); > } > > static int corosync_main_config_log_destination_set ( > - struct objdb_iface_ver0 *objdb, > - hdb_handle_t object_handle, > + const char *path, > + const char *key, > const char *subsys, > const char **error_string, > - const char *objdb_key, > unsigned int mode_mask, > char deprecated, > const char *replacement) > { > static char formatted_error_reason[128]; > - char *value; > + char *value = NULL; > unsigned int mode; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > > - if (!objdb_get_string (objdb, object_handle, objdb_key, &value)) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.%s", path, key); > + if (icmap_get_string(key_name, &value) == CS_OK) { > if (deprecated) { > log_printf(LOGSYS_LEVEL_WARNING, > "Warning: the %s config paramater has been obsoleted." > " See corosync.conf man page %s directive.", > - objdb_key, replacement); > + key, replacement); > } > > mode = logsys_config_mode_get (subsys); > @@ -283,37 +241,40 @@ static int corosync_main_config_log_destination_set ( > if (strcmp (value, "yes") == 0 || strcmp (value, "on") == 0) { > mode |= mode_mask; > if (logsys_config_mode_set(subsys, mode) < 0) { > - sprintf (formatted_error_reason, "unable to set mode %s", objdb_key); > - *error_string = formatted_error_reason; > - return -1; > + sprintf (formatted_error_reason, "unable to set mode %s", key); > + goto parse_error; > } > } else > if (strcmp (value, "no") == 0 || strcmp (value, "off") == 0) { > mode &= ~mode_mask; > if (logsys_config_mode_set(subsys, mode) < 0) { > - sprintf (formatted_error_reason, "unable to unset mode %s", objdb_key); > - *error_string = formatted_error_reason; > - return -1; > + sprintf (formatted_error_reason, "unable to unset mode %s", key); > + goto parse_error; > } > } else { > - sprintf (formatted_error_reason, "unknown value for %s", objdb_key); > - *error_string = formatted_error_reason; > - return -1; > + sprintf (formatted_error_reason, "unknown value for %s", key); > + goto parse_error; > } > } > > - return 0; > + free(value); > + return (0); > + > +parse_error: > + *error_string = formatted_error_reason; > + free(value); > + return (-1); > } > > static int corosync_main_config_set ( > - struct objdb_iface_ver0 *objdb, > - hdb_handle_t object_handle, > + const char *path, > const char *subsys, > const char **error_string) > { > const char *error_reason = error_string_response; > char *value; > int mode; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > > /* > * this bit abuses the internal logsys exported API > @@ -337,19 +298,16 @@ static int corosync_main_config_set ( > goto parse_error; > } > > - if (corosync_main_config_log_destination_set (objdb, object_handle, subsys, &error_reason, > - "to_stderr", LOGSYS_MODE_OUTPUT_STDERR, 0, NULL) != 0) > - goto parse_error; > - > - if (corosync_main_config_log_destination_set (objdb, object_handle, subsys, &error_reason, > - "to_syslog", LOGSYS_MODE_OUTPUT_SYSLOG, 0, NULL) != 0) > + if (corosync_main_config_log_destination_set (path, "to_stderr", subsys, &error_reason, > + LOGSYS_MODE_OUTPUT_STDERR, 0, NULL) != 0) > goto parse_error; > > - if (corosync_main_config_log_destination_set (objdb, object_handle, subsys, &error_reason, > - "to_file", LOGSYS_MODE_OUTPUT_FILE, 1, "to_logfile") != 0) > + if (corosync_main_config_log_destination_set (path, "to_syslog", subsys, &error_reason, > + LOGSYS_MODE_OUTPUT_SYSLOG, 0, NULL) != 0) > goto parse_error; > > - if (!objdb_get_string (objdb,object_handle, "syslog_facility", &value)) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_facility"); > + if (icmap_get_string(key_name, &value) == CS_OK) { > int syslog_facility; > > syslog_facility = qb_log_facility2int(value); > @@ -362,9 +320,12 @@ static int corosync_main_config_set ( > error_reason = "unable to set syslog facility"; > goto parse_error; > } > + > + free(value); > } > > - if (!objdb_get_string (objdb,object_handle, "syslog_level", &value)) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_level"); > + if (icmap_get_string(key_name, &value) == CS_OK) { > int syslog_priority; > > log_printf(LOGSYS_LEVEL_WARNING, > @@ -381,9 +342,11 @@ static int corosync_main_config_set ( > error_reason = "unable to set syslog level"; > goto parse_error; > } > + free(value); > } > > - if (!objdb_get_string (objdb,object_handle, "syslog_priority", &value)) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_priority"); > + if (icmap_get_string(key_name, &value) == CS_OK) { > int syslog_priority; > > syslog_priority = logsys_priority_id_get(value); > @@ -396,19 +359,27 @@ static int corosync_main_config_set ( > error_reason = "unable to set syslog priority"; > goto parse_error; > } > + free(value); > } > > - if (!objdb_get_string (objdb,object_handle, "logfile", &value)) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.%s", path, "logfile"); > + if (icmap_get_string(key_name, &value) == CS_OK) { > if (logsys_config_file_set (subsys, error_string, value) < 0) { > goto parse_error; > } > + free(value); > } > > - if (corosync_main_config_log_destination_set (objdb, object_handle, subsys, &error_reason, > - "to_logfile", LOGSYS_MODE_OUTPUT_FILE, 0, NULL) != 0) > + if (corosync_main_config_log_destination_set (path, "to_file", subsys, &error_reason, > + LOGSYS_MODE_OUTPUT_FILE, 1, "to_logfile") != 0) > + goto parse_error; > + > + if (corosync_main_config_log_destination_set (path, "to_logfile", subsys, &error_reason, > + LOGSYS_MODE_OUTPUT_FILE, 0, NULL) != 0) > goto parse_error; > > - if (!objdb_get_string (objdb,object_handle, "logfile_priority", &value)) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.%s", path, "logfile_priority"); > + if (icmap_get_string(key_name, &value) == CS_OK) { > int logfile_priority; > > logfile_priority = logsys_priority_id_get(value); > @@ -421,9 +392,11 @@ static int corosync_main_config_set ( > error_reason = "unable to set logfile priority"; > goto parse_error; > } > + free(value); > } > > - if (!objdb_get_string (objdb, object_handle, "debug", &value)) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s.%s", path, "debug"); > + if (icmap_get_string(key_name, &value) == CS_OK) { > if (strcmp (value, "on") == 0) { > if (logsys_config_debug_set (subsys, 1) < 0) { > error_reason = "unable to set debug on"; > @@ -439,125 +412,60 @@ static int corosync_main_config_set ( > error_reason = "unknown value for debug"; > goto parse_error; > } > + free(value); > } > > return (0); > > parse_error: > *error_string = error_reason; > + free(value); > > return (-1); > } > > static int corosync_main_config_read_logging ( > - struct objdb_iface_ver0 *objdb, > const char **error_string) > { > - hdb_handle_t object_service_handle; > - hdb_handle_t object_logger_subsys_handle; > - hdb_handle_t object_find_handle; > - hdb_handle_t object_find_logsys_handle; > const char *error_reason; > - char *value; > + icmap_iter_t iter; > + const char *key_name; > + char key_subsys[ICMAP_KEYNAME_MAXLEN]; > + char key_item[ICMAP_KEYNAME_MAXLEN]; > + int res; > > - objdb->object_find_create ( > - OBJECT_PARENT_HANDLE, > - "logging", > - strlen ("logging"), > - &object_find_handle); > + /* format set is supported only for toplevel */ > + if (corosync_main_config_format_set(&error_reason) < 0) { > + goto parse_error; > + } > > - if (objdb->object_find_next ( > - object_find_handle, > - &object_service_handle) == 0) { > + if (corosync_main_config_set ("logging", NULL, &error_reason) < 0) { > + goto parse_error; > + } > > - /* format set is supported only for toplevel */ > - if (corosync_main_config_format_set (objdb, > - object_service_handle, > - &error_reason) < 0) { > - goto parse_error; > - } > + /* > + * we will need 2 of these to compensate for new logging > + * config format > + */ > + iter = icmap_iter_init("logging.logger_subsys."); > + while ((key_name = icmap_iter_next(iter, NULL, NULL)) != NULL) { > + res = sscanf(key_name, "logging.logger_subsys.%[^.].%s", key_subsys, key_item); > > - if (corosync_main_config_set (objdb, > - object_service_handle, > - NULL, > - &error_reason) < 0) { > - goto parse_error; > + if (res != 2) { > + continue ; > } > > - /* we will need 2 of these to compensate for new logging > - * config format */ > - > - objdb->object_find_create ( > - object_service_handle, > - "logger_subsys", > - strlen ("logger_subsys"), > - &object_find_logsys_handle); > - > - while (objdb->object_find_next ( > - object_find_logsys_handle, > - &object_logger_subsys_handle) == 0) { > - > - if (!objdb_get_string (objdb, > - object_logger_subsys_handle, > - "subsys", &value)) { > - > - if (corosync_main_config_set (objdb, > - object_logger_subsys_handle, > - value, > - &error_reason) < 0) { > - goto parse_error; > - } > - } > - else { > - error_reason = "subsys required for logger directive"; > - goto parse_error; > - } > + if (strcmp(key_item, "subsys") != 0) { > + continue ; > } > - objdb->object_find_destroy (object_find_logsys_handle); > - > - objdb->object_find_create ( > - object_service_handle, > - "logging_daemon", > - strlen ("logging_daemon"), > - &object_find_logsys_handle); > - > - while (objdb->object_find_next ( > - object_find_logsys_handle, > - &object_logger_subsys_handle) == 0) { > - > - if (!objdb_get_string (objdb, > - object_logger_subsys_handle, > - "name", &value)) { > - > - if (strcmp(value, "corosync") == 0) { > - if (!objdb_get_string (objdb, > - object_logger_subsys_handle, > - "subsys", &value)) { > - if (corosync_main_config_set (objdb, > - object_logger_subsys_handle, > - value, > - &error_reason) < 0) { > - goto parse_error; > - } > - } > - else { > - if (corosync_main_config_set (objdb, > - object_logger_subsys_handle, > - NULL, > - &error_reason) < 0) { > - goto parse_error; > - } > - } > - } > - } > - else { > - error_reason = "name required for logging_daemon directive"; > - goto parse_error; > - } > + > + snprintf(key_item, ICMAP_KEYNAME_MAXLEN, "logging.logger_subsys.%s", key_subsys); > + > + if (corosync_main_config_set(key_item, key_subsys, &error_reason) < 0) { > + goto parse_error; > } > - objdb->object_find_destroy (object_find_logsys_handle); > } > - objdb->object_find_destroy (object_find_handle); > + icmap_iter_finalize(iter); > > logsys_config_apply(); > return 0; > @@ -568,159 +476,46 @@ parse_error: > return (-1); > } > > -static int uid_determine (const char *req_user) > -{ > - int pw_uid = 0; > - struct passwd passwd; > - struct passwd* pwdptr = &passwd; > - struct passwd* temp_pwd_pt; > - char *pwdbuffer; > - int pwdlinelen; > - > - pwdlinelen = sysconf (_SC_GETPW_R_SIZE_MAX); > - > - if (pwdlinelen == -1) { > - pwdlinelen = 256; > - } > - > - pwdbuffer = malloc (pwdlinelen); > - > - if ((getpwnam_r (req_user, pwdptr, pwdbuffer, pwdlinelen, &temp_pwd_pt)) != 0) { > - log_printf (LOGSYS_LEVEL_ERROR, > - "ERROR: The '%s' user is not found in /etc/passwd, please read the documentation.\n", > - req_user); > - corosync_exit_error (AIS_DONE_UID_DETERMINE); > - } > - pw_uid = passwd.pw_uid; > - free (pwdbuffer); > - > - return pw_uid; > -} > - > -static int gid_determine (const char *req_group) > -{ > - int ais_gid = 0; > - struct group group; > - struct group * grpptr = &group; > - struct group * temp_grp_pt; > - char *grpbuffer; > - int grplinelen; > - > - grplinelen = sysconf (_SC_GETGR_R_SIZE_MAX); > - > - if (grplinelen == -1) { > - grplinelen = 256; > - } > - > - grpbuffer = malloc (grplinelen); > - > - if ((getgrnam_r (req_group, grpptr, grpbuffer, grplinelen, &temp_grp_pt)) != 0) { > - log_printf (LOGSYS_LEVEL_ERROR, > - "ERROR: The '%s' group is not found in /etc/group, please read the documentation.\n", > - req_group); > - corosync_exit_error (AIS_DONE_GID_DETERMINE); > - } > - ais_gid = group.gr_gid; > - free (grpbuffer); > - > - return ais_gid; > -} > - > - > -static void main_objdb_reload_notify(objdb_reload_notify_type_t type, int flush, > - void *priv_data_pt) > +static void main_logging_notify( > + int32_t event, > + const char *key_name, > + struct icmap_notify_value new_val, > + struct icmap_notify_value old_val, > + void *user_data) > { > const char *error_string; > > - if (type == OBJDB_RELOAD_NOTIFY_END) { > - > - /* > - * Reload the logsys configuration > - */ > - if (logsys_format_set(NULL) == -1) { > - fprintf (stderr, "Unable to setup logging format.\n"); > - } > - corosync_main_config_read_logging(global_objdb, > - &error_string); > + /* > + * Reload the logsys configuration > + */ > + if (logsys_format_set(NULL) == -1) { > + fprintf (stderr, "Unable to setup logging format.\n"); > } > + corosync_main_config_read_logging(&error_string); > } > > -static void add_logsys_config_notification( > - struct objdb_iface_ver0 *objdb) > +static void add_logsys_config_notification(void) > { > + icmap_track_t icmap_track; > > - global_objdb = objdb; > - > - objdb->object_track_start(OBJECT_PARENT_HANDLE, > - 1, > - NULL, > - NULL, > - NULL, > - main_objdb_reload_notify, > - NULL); > - > -} > - > -static int corosync_main_config_read_uidgid ( > - struct objdb_iface_ver0 *objdb, > - const char **error_string) > -{ > - hdb_handle_t object_find_handle; > - hdb_handle_t object_service_handle; > - char *value; > - int uid, gid; > - struct uidgid_item *ugi; > - > - objdb->object_find_create ( > - OBJECT_PARENT_HANDLE, > - "uidgid", > - strlen ("uidgid"), > - &object_find_handle); > - > - while (objdb->object_find_next ( > - object_find_handle, > - &object_service_handle) == 0) { > - uid = -1; > - gid = -1; > - > - if (!objdb_get_string (objdb,object_service_handle, "uid", &value)) { > - uid = uid_determine(value); > - } > - > - if (!objdb_get_string (objdb,object_service_handle, "gid", &value)) { > - gid = gid_determine(value); > - } > - > - if (uid > -1 || gid > -1) { > - ugi = malloc (sizeof (*ugi)); > - if (ugi == NULL) { > - _corosync_out_of_memory_error(); > - } > - ugi->uid = uid; > - ugi->gid = gid; > - list_init (&ugi->list); > - list_add (&ugi->list, &uidgid_list_head); > - } > - } > - objdb->object_find_destroy (object_find_handle); > - > - return 0; > + icmap_track_add("logging.", > + ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY | ICMAP_TRACK_PREFIX, > + main_logging_notify, > + NULL, > + &icmap_track); > } > > int corosync_main_config_read ( > - struct objdb_iface_ver0 *objdb, > const char **error_string) > { > const char *error_reason = error_string_response; > > - if (corosync_main_config_read_logging(objdb, error_string) < 0) { > + if (corosync_main_config_read_logging(error_string) < 0) { > error_reason = *error_string; > goto parse_error; > } > > - corosync_main_config_read_uidgid (objdb, error_string); > - > - add_logsys_config_notification(objdb); > + add_logsys_config_notification(); > > return 0; > > @@ -734,7 +529,6 @@ parse_error: > } > > int corosync_main_config_compatibility_read ( > - struct objdb_iface_ver0 *objdb, > enum cs_sync_mode *minimum_sync_mode, > const char **error_string) > { > @@ -742,8 +536,7 @@ int corosync_main_config_compatibility_read ( > char *value; > > *minimum_sync_mode = CS_SYNC_V1; > - if (!objdb_get_string (objdb, OBJECT_PARENT_HANDLE, "compatibility", &value)) { > - > + if (icmap_get_string("compatibility", &value) == CS_OK) { > if (strcmp (value, "whitetank") == 0) { > *minimum_sync_mode = CS_SYNC_V1; > } else > @@ -755,12 +548,13 @@ int corosync_main_config_compatibility_read ( > "Invalid compatibility option '%s' specified, must be none or whitetank.\n", value); > goto parse_error; > } > + free(value); > } > > return 0; > > parse_error: > *error_string = error_reason; > - > + free(value); > return (-1); > } > diff --git a/exec/mainconfig.h b/exec/mainconfig.h > index b8d4ff9..5f7a2c2 100644 > --- a/exec/mainconfig.h > +++ b/exec/mainconfig.h > @@ -35,7 +35,6 @@ > #ifndef MAINCONFIG_H_DEFINED > #define MAINCONFIG_H_DEFINED > > -#include <corosync/engine/objdb.h> > #include <corosync/engine/logsys.h> > #include <corosync/list.h> > #include <corosync/engine/coroapi.h> > @@ -47,27 +46,13 @@ struct dynamic_service { > char *name; > unsigned int ver; > unsigned int handle; > - struct corosync_service_engine_iface_ver0 *iface_ver0; > }; > #define MAX_DYNAMIC_SERVICES 128 > > -/** > - * Structure describing cached uidgid item > - */ > -struct uidgid_item { > - struct list_head list; > - int uid; > - int gid; > -}; > - > -extern struct list_head uidgid_list_head; > - > extern int corosync_main_config_read ( > - struct objdb_iface_ver0 *objdb, > const char **error_string); > > extern int corosync_main_config_compatibility_read ( > - struct objdb_iface_ver0 *objdb, > enum cs_sync_mode *minimum_sync_mode, > const char **error_string); > > diff --git a/exec/objdb.c b/exec/objdb.c > index 37a521a..8988600 100644 > --- a/exec/objdb.c > +++ b/exec/objdb.c > @@ -1753,16 +1753,16 @@ static int object_write_config(const char **error_string) > struct config_iface_ver0 **modules; > int num_modules; > int i; > - int res; > +// int res; > > main_get_config_modules(&modules, &num_modules); > > for (i=0; i<num_modules; i++) { > if (modules[i]->config_writeconfig) { > - res = modules[i]->config_writeconfig(&objdb_iface, error_string); > +/* res = modules[i]->config_writeconfig(&objdb_iface, error_string); > if (res) { > return res; > - } > + }*/ > } > } > return 0; > @@ -1773,18 +1773,18 @@ static int object_reload_config(int flush, const char **error_string) > struct config_iface_ver0 **modules; > int num_modules; > int i; > - int res; > +/* int res = 0; */ > > main_get_config_modules(&modules, &num_modules); > object_reload_notification(OBJDB_RELOAD_NOTIFY_START, flush); > > for (i=0; i<num_modules; i++) { > if (modules[i]->config_reloadconfig) { > - res = modules[i]->config_reloadconfig(&objdb_iface, flush, error_string); > +/* res = modules[i]->config_reloadconfig(&objdb_iface, flush, error_string); > if (res) { > object_reload_notification(OBJDB_RELOAD_NOTIFY_FAILED, flush); > return res; > - } > + } */ > } > } > object_reload_notification(OBJDB_RELOAD_NOTIFY_END, flush); > diff --git a/exec/service.c b/exec/service.c > index 3e3b1b3..59c1028 100644 > --- a/exec/service.c > +++ b/exec/service.c > @@ -46,6 +46,7 @@ > #include "mainconfig.h" > #include "util.h" > #include <corosync/engine/logsys.h> > +#include <corosync/engine/icmap.h> > > #include "timer.h" > #include <corosync/totem/totempg.h> > @@ -78,10 +79,6 @@ static struct default_service default_services[] = { > .ver = 0, > }, > { > - .name = "corosync_confdb", > - .ver = 0, > - }, > - { > .name = "corosync_pload", > .ver = 0, > }, > @@ -100,7 +97,11 @@ static struct default_service default_services[] = { > { > .name = "corosync_quorum", > .ver = 0, > - } > + }, > + { > + .name = "corosync_cmap", > + .ver = 0, > + }, > }; > > /* > @@ -114,50 +115,30 @@ struct seus_handler_data { > > struct corosync_service_engine *ais_service[SERVICE_HANDLER_MAXIMUM_COUNT]; > > -hdb_handle_t service_stats_handle[SERVICE_HANDLER_MAXIMUM_COUNT][64]; > +const char *service_stats_rx[SERVICE_HANDLER_MAXIMUM_COUNT][64]; > +const char *service_stats_tx[SERVICE_HANDLER_MAXIMUM_COUNT][64]; > > int ais_service_exiting[SERVICE_HANDLER_MAXIMUM_COUNT]; > > -static hdb_handle_t object_internal_configuration_handle; > - > -static hdb_handle_t object_stats_services_handle; > - > static void (*service_unlink_all_complete) (void) = NULL; > > static unsigned int default_services_requested (struct corosync_api_v1 *corosync_api) > { > - hdb_handle_t object_service_handle; > - hdb_handle_t object_find_handle; > - char *value; > + char *value = NULL; > + int res; > > /* > * Don't link default services if they have been disabled > */ > - corosync_api->object_find_create ( > - OBJECT_PARENT_HANDLE, > - "aisexec", > - strlen ("aisexec"), > - &object_find_handle); > - > - if (corosync_api->object_find_next ( > - object_find_handle, > - &object_service_handle) == 0) { > - > - if ( ! corosync_api->object_key_get (object_service_handle, > - "defaultservices", > - strlen ("defaultservices"), > - (void *)&value, > - NULL)) { > - > - if (value && strcmp (value, "no") == 0) { > - return 0; > - } > - } > + if (icmap_get_string("aisexec.defaultservices", &value) == CS_OK && > + value != NULL && strcmp(value, "no") == 0) { > + res = 0; > + } else { > + res = -1; > } > > - corosync_api->object_find_destroy (object_find_handle); > - > - return (-1); > + free(value); > + return (res); > } > > unsigned int corosync_service_link_and_init ( > @@ -170,14 +151,11 @@ unsigned int corosync_service_link_and_init ( > hdb_handle_t handle; > struct corosync_service_engine *service; > int res; > - hdb_handle_t object_service_handle; > - hdb_handle_t object_stats_handle; > int fn; > - char object_name[32]; > char *name_sufix; > - uint64_t zero_64 = 0; > void* _start; > void* _stop; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > > /* > * reference the service interface > @@ -220,32 +198,16 @@ unsigned int corosync_service_link_and_init ( > } > > /* > - * Store service in object database > + * Store service in cmap db > */ > - corosync_api->object_create (object_internal_configuration_handle, > - &object_service_handle, > - "service", > - strlen ("service")); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "internal_configuration.service.%u.name", service->id); > + icmap_set_string(key_name, service_name); > > - corosync_api->object_key_create_typed (object_service_handle, > - "name", > - service_name, > - strlen (service_name) + 1, OBJDB_VALUETYPE_STRING); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "internal_configuration.service.%u.ver", service->id); > + icmap_set_uint32(key_name, service_ver); > > - corosync_api->object_key_create_typed (object_service_handle, > - "ver", > - &service_ver, > - sizeof (service_ver), OBJDB_VALUETYPE_UINT32); > - > - res = corosync_api->object_key_create_typed (object_service_handle, > - "handle", > - &handle, > - sizeof (handle), OBJDB_VALUETYPE_UINT64); > - > - corosync_api->object_key_create_typed (object_service_handle, > - "service_id", > - &service->id, > - sizeof (service->id), OBJDB_VALUETYPE_UINT16); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "internal_configuration.service.%u.handle", service->id); > + icmap_set_uint64(key_name, handle); > > name_sufix = strrchr (service_name, '_'); > if (name_sufix) > @@ -253,31 +215,17 @@ unsigned int corosync_service_link_and_init ( > else > name_sufix = (char*)service_name; > > - corosync_api->object_create (object_stats_services_handle, > - &object_stats_handle, > - name_sufix, strlen (name_sufix)); > - > - corosync_api->object_key_create_typed (object_stats_handle, > - "service_id", > - &service->id, sizeof (service->id), > - OBJDB_VALUETYPE_INT16); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "runtime.services.%s.service_id", name_sufix); > + icmap_set_uint16(key_name, service->id); > > for (fn = 0; fn < service->exec_engine_count; fn++) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "runtime.services.%s.%d.tx", name_sufix, fn); > + icmap_set_uint64(key_name, 0); > + service_stats_tx[service->id][fn] = strdup(key_name); > > - snprintf (object_name, 32, "%d", fn); > - corosync_api->object_create (object_stats_handle, > - &service_stats_handle[service->id][fn], > - object_name, strlen (object_name)); > - > - corosync_api->object_key_create_typed (service_stats_handle[service->id][fn], > - "tx", > - &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > - > - corosync_api->object_key_create_typed (service_stats_handle[service->id][fn], > - "rx", > - &zero_64, sizeof (zero_64), > - OBJDB_VALUETYPE_UINT64); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "runtime.services.%s.%d.rx", name_sufix, fn); > + icmap_set_uint64(key_name, 0); > + service_stats_rx[service->id][fn] = strdup(key_name); > } > > log_printf (LOGSYS_LEVEL_NOTICE, > @@ -308,10 +256,10 @@ corosync_service_unlink_priority ( > int *current_service_engine, > hdb_handle_t *current_service_handle) > { > - unsigned short *service_id; > - hdb_handle_t object_service_handle; > - hdb_handle_t object_find_handle; > - hdb_handle_t *found_service_handle; > + unsigned short service_id; > + hdb_handle_t found_service_handle; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > + int res; > > for(; *current_priority >= lowest_priority; *current_priority = *current_priority - 1) { > for(*current_service_engine = 0; > @@ -324,56 +272,33 @@ corosync_service_unlink_priority ( > } > > /* > - * find service object in object database by service id > - * and unload it if possible. > + * find service handle and unload it if possible. > * > * If the service engine's exec_exit_fn returns -1 indicating > * it was busy, this function returns -1 and can be called again > * at a later time (usually via the schedwrk api). > */ > - corosync_api->object_find_create ( > - object_internal_configuration_handle, > - "service", strlen ("service"), &object_find_handle); > - > - while (corosync_api->object_find_next ( > - object_find_handle, &object_service_handle) == 0) { > - > - int res = corosync_api->object_key_get ( > - object_service_handle, > - "service_id", strlen ("service_id"), > - (void *)&service_id, NULL); > - > - if (res == 0 && *service_id == > - ais_service[*current_service_engine]->id) { > - > - if (ais_service[*service_id]->exec_exit_fn) { > - res = ais_service[*service_id]->exec_exit_fn (); > - if (res == -1) { > - corosync_api->object_find_destroy (object_find_handle); > - return (-1); > - } > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, > + "internal_configuration.service.%u.handle", > + ais_service[*current_service_engine]->id); > + if (icmap_get_uint64(key_name, &found_service_handle) == CS_OK) { > + service_id = ais_service[*current_service_engine]->id; > + > + if (ais_service[service_id]->exec_exit_fn) { > + res = ais_service[service_id]->exec_exit_fn (); > + if (res == -1) { > + return (-1); > } > + } > > - res = corosync_api->object_key_get ( > - object_service_handle, > - "handle", strlen ("handle"), > - (void *)&found_service_handle, > - NULL); > - > - *current_service_handle = *found_service_handle; > - > - ais_service_exiting[*current_service_engine] = 1; > - > - corosync_api->object_find_destroy (object_find_handle); > + *current_service_handle = found_service_handle; > + ais_service_exiting[*current_service_engine] = 1; > > - /* > - * Call should call this function again > - */ > - return (1); > - } > + /* > + * Call should call this function again > + */ > + return (1); > } > - > - corosync_api->object_find_destroy (object_find_handle); > } > } > /* > @@ -387,14 +312,16 @@ static unsigned int service_unlink_and_exit ( > const char *service_name, > unsigned int service_ver) > { > - hdb_handle_t object_service_handle; > - char *found_service_name; > - unsigned short *service_id; > - unsigned int *found_service_ver; > - hdb_handle_t object_find_handle; > - hdb_handle_t *found_service_handle; > + unsigned short service_id; > + hdb_handle_t found_service_handle; > char *name_sufix; > int res; > + const char *iter_key_name; > + icmap_iter_t iter; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > + unsigned int found_service_ver; > + char *found_service_name; > + int service_found; > > name_sufix = strrchr (service_name, '_'); > if (name_sufix) > @@ -402,93 +329,65 @@ static unsigned int service_unlink_and_exit ( > else > name_sufix = (char*)service_name; > > - corosync_api->object_find_create ( > - object_stats_services_handle, > - name_sufix, strlen (name_sufix), > - &object_find_handle); > - > - if (corosync_api->object_find_next ( > - object_find_handle, > - &object_service_handle) == 0) { > > - corosync_api->object_destroy (object_service_handle); > - > - } > - corosync_api->object_find_destroy (object_find_handle); > - > - > - corosync_api->object_find_create ( > - object_internal_configuration_handle, > - "service", > - strlen ("service"), > - &object_find_handle); > - > - while (corosync_api->object_find_next ( > - object_find_handle, > - &object_service_handle) == 0) { > - > - corosync_api->object_key_get (object_service_handle, > - "name", > - strlen ("name"), > - (void *)&found_service_name, > - NULL); > - > - if (strcmp (service_name, found_service_name) != 0) { > - continue; > + service_found = 0; > + found_service_name = NULL; > + iter = icmap_iter_init("internal_configuration.service."); > + while ((iter_key_name = icmap_iter_next(iter, NULL, NULL)) != NULL) { > + res = sscanf(iter_key_name, "internal_configuration.service.%hu.%s", &service_id, key_name); > + if (res != 2) { > + continue; > } > > - corosync_api->object_key_get (object_service_handle, > - "ver", > - strlen ("ver"), > - (void *)&found_service_ver, > - NULL); > - > - /* > - * If service found and linked exit it > - */ > - if (service_ver != *found_service_ver) { > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "internal_configuration.service.%hu.name", service_id); > + free(found_service_name); > + if (icmap_get_string(key_name, &found_service_name) != CS_OK) { > continue; > } > > - corosync_api->object_key_get ( > - object_service_handle, > - "service_id", strlen ("service_id"), > - (void *)&service_id, NULL); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "internal_configuration.service.%u.ver", service_id); > + if (icmap_get_uint32(key_name, &found_service_ver) != CS_OK) { > + continue; > + } > > - if(service_id != NULL > - && *service_id < SERVICE_HANDLER_MAXIMUM_COUNT > - && ais_service[*service_id] != NULL) { > + if (service_ver == found_service_ver && strcmp(found_service_name, service_name) == 0) { > + free(found_service_name); > + service_found = 1; > + break; > + } > + } > + icmap_iter_finalize(iter); > > - corosync_api->object_find_destroy (object_find_handle); > + if (service_found && service_id < SERVICE_HANDLER_MAXIMUM_COUNT > + && ais_service[service_id] != NULL) { > > - if (ais_service[*service_id]->exec_exit_fn) { > - res = ais_service[*service_id]->exec_exit_fn (); > - if (res == -1) { > - return (-1); > - } > + if (ais_service[service_id]->exec_exit_fn) { > + res = ais_service[service_id]->exec_exit_fn (); > + if (res == -1) { > + return (-1); > } > + } > > - log_printf(LOGSYS_LEVEL_NOTICE, > - "Service engine unloaded: %s\n", > - ais_service[*service_id]->name); > - > - ais_service[*service_id] = NULL; > - > - res = corosync_api->object_key_get ( > - object_service_handle, > - "handle", strlen ("handle"), > - (void *)&found_service_handle, > - NULL); > + log_printf(LOGSYS_LEVEL_NOTICE, > + "Service engine unloaded: %s\n", > + ais_service[service_id]->name); > > - cs_ipcs_service_destroy (*service_id); > + ais_service[service_id] = NULL; > > - lcr_ifact_release (*found_service_handle); > + cs_ipcs_service_destroy (service_id); > > - corosync_api->object_destroy (object_service_handle); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "internal_configuration.service.%u.handle", service_id); > + if (icmap_get_uint64(key_name, &found_service_handle) == CS_OK) { > + lcr_ifact_release (found_service_handle); > } > - } > > - corosync_api->object_find_destroy (object_find_handle); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "internal_configuration.service.%u.handle", service_id); > + icmap_delete(key_name); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "internal_configuration.service.%u.name", service_id); > + icmap_delete(key_name); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "internal_configuration.service.%u.ver", service_id); > + icmap_delete(key_name); > + } > > return (0); > } > @@ -500,68 +399,45 @@ unsigned int corosync_service_defaults_link_and_init (struct corosync_api_v1 *co > { > unsigned int i; > > - hdb_handle_t object_service_handle; > + icmap_iter_t iter; > char *found_service_name; > - char *found_service_ver; > - unsigned int found_service_ver_atoi; > - hdb_handle_t object_find_handle; > - hdb_handle_t object_find2_handle; > - hdb_handle_t object_runtime_handle; > - > - corosync_api->object_find_create ( > - OBJECT_PARENT_HANDLE, > - "runtime", > - strlen ("runtime"), > - &object_find2_handle); > - > - if (corosync_api->object_find_next ( > - object_find2_handle, > - &object_runtime_handle) == 0) { > - > - corosync_api->object_create (object_runtime_handle, > - &object_stats_services_handle, > - "services", strlen ("services")); > - } > - corosync_api->object_find_destroy (object_find2_handle); > - > - corosync_api->object_create (OBJECT_PARENT_HANDLE, > - &object_internal_configuration_handle, > - "internal_configuration", > - strlen ("internal_configuration")); > - > - corosync_api->object_find_create ( > - OBJECT_PARENT_HANDLE, > - "service", > - strlen ("service"), > - &object_find_handle); > - > - while (corosync_api->object_find_next ( > - object_find_handle, > - &object_service_handle) == 0) { > - > - corosync_api->object_key_get (object_service_handle, > - "name", > - strlen ("name"), > - (void *)&found_service_name, > - NULL); > - > - found_service_ver = NULL; > + int res; > + unsigned int found_service_ver; > + const char *iter_key_name; > + unsigned int service_pos; > + char key_name[ICMAP_KEYNAME_MAXLEN]; > + > + icmap_set_ro_access("internal_configuration.", 1, 1); > + icmap_set_ro_access("runtime.services.", 1, 1); > + > + found_service_name = NULL; > + iter = icmap_iter_init("service."); > + while ((iter_key_name = icmap_iter_next(iter, NULL, NULL)) != NULL) { > + res = sscanf(iter_key_name, "service.%u.%s", &service_pos, key_name); > + if (res != 2) { > + continue; > + } > + if (strcmp(key_name, "name") != 0) { > + continue; > + } > > - corosync_api->object_key_get (object_service_handle, > - "ver", > - strlen ("ver"), > - (void *)&found_service_ver, > - NULL); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "service.%u.name", service_pos); > + free(found_service_name); > + if (icmap_get_string(key_name, &found_service_name) != CS_OK) { > + continue; > + } > > - found_service_ver_atoi = (found_service_ver ? atoi (found_service_ver) : 0); > + snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "service.%u.ver", service_pos); > + if (icmap_get_uint32(key_name, &found_service_ver) != CS_OK) { > + continue; > + } > > corosync_service_link_and_init ( > corosync_api, > found_service_name, > - found_service_ver_atoi); > + found_service_ver); > } > - > - corosync_api->object_find_destroy (object_find_handle); > + icmap_iter_finalize(iter); > > if (default_services_requested (corosync_api) == 0) { > return (0); > diff --git a/exec/service.h b/exec/service.h > index b7b934a..1ff132d 100644 > --- a/exec/service.h > +++ b/exec/service.h > @@ -72,6 +72,7 @@ extern struct corosync_service_engine *ais_service[]; > > extern int ais_service_exiting[]; > > -extern hdb_handle_t service_stats_handle[SERVICE_HANDLER_MAXIMUM_COUNT][64]; > +extern const char *service_stats_rx[SERVICE_HANDLER_MAXIMUM_COUNT][64]; > +extern const char *service_stats_tx[SERVICE_HANDLER_MAXIMUM_COUNT][64]; > > #endif /* SERVICE_H_DEFINED */ > diff --git a/exec/totemconfig.c b/exec/totemconfig.c > index a74017a..1248a72 100644 > --- a/exec/totemconfig.c > +++ b/exec/totemconfig.c > @@ -1,10 +1,11 @@ > /* > * Copyright (c) 2002-2005 MontaVista Software, Inc. > - * Copyright (c) 2006-2010 Red Hat, Inc. > + * Copyright (c) 2006-2011 Red Hat, Inc. > * > * All rights reserved. > * > * Author: Steven Dake (sdake@xxxxxxxxxx) > + * Jan Friesse (jfriesse@xxxxxxxxxx) > * > * This software licensed under BSD license, the text of which follows: > * > @@ -52,9 +53,9 @@ > #include <corosync/list.h> > #include <qb/qbdefs.h> > #include <corosync/totem/totem.h> > -#include <corosync/engine/objdb.h> > #include <corosync/engine/config.h> > #include <corosync/engine/logsys.h> > +#include <corosync/engine/icmap.h> > > #ifdef HAVE_LIBNSS > #include <nss.h> > @@ -86,162 +87,50 @@ > #define RRP_AUTORECOVERY_CHECK_TIMEOUT 1000 > > static char error_string_response[512]; > -static struct objdb_iface_ver0 *global_objdb; > - > -static void add_totem_config_notification( > - struct objdb_iface_ver0 *objdb, > - struct totem_config *totem_config, > - hdb_handle_t totem_object_handle); > > +static void add_totem_config_notification(struct totem_config *totem_config); > > -/* These just makes the code below a little neater */ > -static inline int objdb_get_string ( > - const struct objdb_iface_ver0 *objdb, > - hdb_handle_t object_service_handle, > - const char *key, const char **value) > +static void totem_volatile_config_read (struct totem_config *totem_config) > { > - int res; > - > - *value = NULL; > - if ( !(res = objdb->object_key_get (object_service_handle, > - key, > - strlen (key), > - (void *)value, > - NULL))) { > - > - if (*value) { > - return 0; > - } > - } > - return -1; > -} > - > -static inline void objdb_get_int ( > - const struct objdb_iface_ver0 *objdb, > - hdb_handle_t object_service_handle, > - const char *key, unsigned int *intvalue) > -{ > - char *value = NULL; > - > - if (!objdb->object_key_get (object_service_handle, > - key, > - strlen (key), > - (void *)&value, > - NULL)) { > - > - if (value) { > - *intvalue = atoi(value); > - } > - } > -} > - > -static unsigned int totem_handle_find ( > - struct objdb_iface_ver0 *objdb, > - hdb_handle_t *totem_find_handle) { > - > - hdb_handle_t object_find_handle; > - unsigned int res; > - > - /* > - * Find a network section > - */ > - objdb->object_find_create ( > - OBJECT_PARENT_HANDLE, > - "network", > - strlen ("network"), > - &object_find_handle); > - > - res = objdb->object_find_next ( > - object_find_handle, > - totem_find_handle); > - > - objdb->object_find_destroy (object_find_handle); > - > - /* > - * Network section not found in configuration, checking for totem > - */ > - if (res == -1) { > - objdb->object_find_create ( > - OBJECT_PARENT_HANDLE, > - "totem", > - strlen ("totem"), > - &object_find_handle); > - > - res = objdb->object_find_next ( > - object_find_handle, > - totem_find_handle); > - > - objdb->object_find_destroy (object_find_handle); > - } > - > - if (res == -1) { > - return (-1); > + char *str; > + > + icmap_get_uint32("totem.token", &totem_config->token_timeout); > + icmap_get_uint32("totem.token_retransmit", &totem_config->token_retransmit_timeout); > + icmap_get_uint32("totem.hold", &totem_config->token_hold_timeout); > + icmap_get_uint32("totem.token_retransmits_before_loss_const", &totem_config->token_retransmits_before_loss_const); > + icmap_get_uint32("totem.join", &totem_config->join_timeout); > + icmap_get_uint32("totem.send_join", &totem_config->send_join_timeout); > + icmap_get_uint32("totem.consensus", &totem_config->consensus_timeout); > + icmap_get_uint32("totem.merge", &totem_config->merge_timeout); > + icmap_get_uint32("totem.downcheck", &totem_config->downcheck_timeout); > + icmap_get_uint32("totem.fail_recv_const", &totem_config->fail_to_recv_const); > + icmap_get_uint32("totem.seqno_unchanged_const", &totem_config->seqno_unchanged_const); > + icmap_get_uint32("totem.rrp_token_expired_timeout", &totem_config->rrp_token_expired_timeout); > + icmap_get_uint32("totem.rrp_problem_count_timeout", &totem_config->rrp_problem_count_timeout); > + icmap_get_uint32("totem.rrp_problem_count_threshold", &totem_config->rrp_problem_count_threshold); > + icmap_get_uint32("totem.rrp_problem_count_mcast_threshold", &totem_config->rrp_problem_count_mcast_threshold); > + icmap_get_uint32("totem.rrp_autorecovery_check_timeout", &totem_config->rrp_autorecovery_check_timeout); > + icmap_get_uint32("totem.heartbeat_failures_allowed", &totem_config->heartbeat_failures_allowed); > + icmap_get_uint32("totem.max_network_delay", &totem_config->max_network_delay); > + icmap_get_uint32("totem.window_size", &totem_config->window_size); > + icmap_get_uint32("totem.max_messages", &totem_config->max_messages); > + icmap_get_uint32("totem.miss_count_const", &totem_config->miss_count_const); > + if (icmap_get_string("totem.vsftype", &str) == CS_OK) { > + totem_config->vsf_type = str; > } > - > - return (0); > -} > - > -static void totem_volatile_config_read ( > - struct objdb_iface_ver0 *objdb, > - struct totem_config *totem_config, > - hdb_handle_t object_totem_handle) > -{ > - objdb_get_int (objdb,object_totem_handle, "token", &totem_config->token_timeout); > - > - objdb_get_int (objdb,object_totem_handle, "token_retransmit", &totem_config->token_retransmit_timeout); > - > - objdb_get_int (objdb,object_totem_handle, "hold", &totem_config->token_hold_timeout); > - > - objdb_get_int (objdb,object_totem_handle, "token_retransmits_before_loss_const", &totem_config->token_retransmits_before_loss_const); > - > - objdb_get_int (objdb,object_totem_handle, "join", &totem_config->join_timeout); > - objdb_get_int (objdb,object_totem_handle, "send_join", &totem_config->send_join_timeout); > - > - objdb_get_int (objdb,object_totem_handle, "consensus", &totem_config->consensus_timeout); > - > - objdb_get_int (objdb,object_totem_handle, "merge", &totem_config->merge_timeout); > - > - objdb_get_int (objdb,object_totem_handle, "downcheck", &totem_config->downcheck_timeout); > - > - objdb_get_int (objdb,object_totem_handle, "fail_recv_const", &totem_config->fail_to_recv_const); > - > - objdb_get_int (objdb,object_totem_handle, "seqno_unchanged_const", &totem_config->seqno_unchanged_const); > - > - objdb_get_int (objdb,object_totem_handle, "rrp_token_expired_timeout", &totem_config->rrp_token_expired_timeout); > - > - objdb_get_int (objdb,object_totem_handle, "rrp_problem_count_timeout", &totem_config->rrp_problem_count_timeout); > - > - objdb_get_int (objdb,object_totem_handle, "rrp_problem_count_threshold", &totem_config->rrp_problem_count_threshold); > - > - objdb_get_int (objdb,object_totem_handle, "rrp_problem_count_mcast_threshold", &totem_config->rrp_problem_count_mcast_threshold); > - > - objdb_get_int (objdb,object_totem_handle, "rrp_autorecovery_check_timeout", &totem_config->rrp_autorecovery_check_timeout); > - > - objdb_get_int (objdb,object_totem_handle, "heartbeat_failures_allowed", &totem_config->heartbeat_failures_allowed); > - > - objdb_get_int (objdb,object_totem_handle, "max_network_delay", &totem_config->max_network_delay); > - > - objdb_get_int (objdb,object_totem_handle, "window_size", &totem_config->window_size); > - (void)objdb_get_string (objdb, object_totem_handle, "vsftype", &totem_config->vsf_type); > - > - objdb_get_int (objdb,object_totem_handle, "max_messages", &totem_config->max_messages); > - > - objdb_get_int (objdb,object_totem_handle, "miss_count_const", &totem_config->miss_count_const); > } > > > -static void totem_get_crypto_type( > - const struct objdb_iface_ver0 *objdb, > - hdb_handle_t object_totem_handle, > - struct totem_config *totem_config) > +static void totem_get_crypto_type(struct totem_config *totem_config) > { > - const char *str; > + char *str; > > totem_config->crypto_accept = TOTEM_CRYPTO_ACCEPT_OLD; > - if (!objdb_get_string (objdb, object_totem_handle, "crypto_accept", &str)) { > + if (icmap_get_string("totem.crypto_accept", &str) == CS_OK) { > if (strcmp(str, "new") == 0) { > totem_config->crypto_accept = TOTEM_CRYPTO_ACCEPT_NEW; > } > + free(str); > } > > totem_config->crypto_type = TOTEM_CRYPTO_SOBER; > @@ -255,42 +144,34 @@ static void totem_get_crypto_type( > totem_config->crypto_sign_type = CKM_SHA256_RSA_PKCS; > #endif > > - if (!objdb_get_string (objdb, object_totem_handle, "crypto_type", &str)) { > + if (icmap_get_string("totem.crypto_type", &str) == CS_OK) { > if (strcmp(str, "sober") == 0) { > + free(str); > return; > } > #ifdef HAVE_LIBNSS > if (strcmp(str, "nss") == 0) { > totem_config->crypto_type = TOTEM_CRYPTO_NSS; > - > } > + free(str); > #endif > } > } > > - > - > extern int totem_config_read ( > - struct objdb_iface_ver0 *objdb, > struct totem_config *totem_config, > const char **error_string) > { > int res = 0; > - hdb_handle_t object_totem_handle; > - hdb_handle_t object_interface_handle; > - hdb_handle_t object_member_handle; > - const char *str; > + char *str; > unsigned int ringnumber = 0; > - hdb_handle_t object_find_interface_handle; > - hdb_handle_t object_find_member_handle; > - const char *transport_type; > int member_count = 0; > - > - res = totem_handle_find (objdb, &object_totem_handle); > - if (res == -1) { > -printf ("couldn't find totem handle\n"); > - return (-1); > - } > + icmap_iter_t iter, member_iter; > + const char *iter_key; > + const char *member_iter_key; > + char ringnumber_key[ICMAP_KEYNAME_MAXLEN]; > + char tmp_key[ICMAP_KEYNAME_MAXLEN]; > + uint8_t u8; > > memset (totem_config, 0, sizeof (struct totem_config)); > totem_config->interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX); > @@ -306,142 +187,138 @@ printf ("couldn't find totem handle\n"); > > strcpy (totem_config->rrp_mode, "none"); > > - if (!objdb_get_string (objdb, object_totem_handle, "version", &str)) { > - if (strcmp (str, "2") == 0) { > - totem_config->version = 2; > - } > - } > - if (!objdb_get_string (objdb, object_totem_handle, "secauth", &str)) { > + icmap_get_uint32("totem.version", (uint32_t *)&totem_config->version); > + > + if (icmap_get_string("totem.secauth", &str) == CS_OK) { > if (strcmp (str, "on") == 0) { > totem_config->secauth = 1; > } > if (strcmp (str, "off") == 0) { > totem_config->secauth = 0; > } > + free(str); > } > > if (totem_config->secauth == 1) { > - totem_get_crypto_type(objdb, object_totem_handle, totem_config); > + totem_get_crypto_type(totem_config); > } > > - if (!objdb_get_string (objdb, object_totem_handle, "rrp_mode", &str)) { > + if (icmap_get_string("totem.rrp_mode", &str) == CS_OK) { > strcpy (totem_config->rrp_mode, str); > + free(str); > } > > /* > * Get interface node id > */ > - objdb_get_int (objdb, object_totem_handle, "nodeid", &totem_config->node_id); > + icmap_get_uint32("totem.nodeid", &totem_config->node_id); > > totem_config->clear_node_high_bit = 0; > - if (!objdb_get_string (objdb,object_totem_handle, "clear_node_high_bit", &str)) { > + if (icmap_get_string("totem.clear_node_high_bit", &str) == CS_OK) { > if (strcmp (str, "yes") == 0) { > totem_config->clear_node_high_bit = 1; > } > + free(str); > } > > - objdb_get_int (objdb,object_totem_handle, "threads", &totem_config->threads); > - > + icmap_get_uint32("totem.threads", &totem_config->threads); > > - objdb_get_int (objdb,object_totem_handle, "netmtu", &totem_config->net_mtu); > + icmap_get_uint32("totem.netmtu", &totem_config->net_mtu); > > /* > * Get things that might change in the future > */ > - totem_volatile_config_read (objdb, totem_config, object_totem_handle); > + totem_volatile_config_read(totem_config); > > - objdb->object_find_create ( > - object_totem_handle, > - "interface", > - strlen ("interface"), > - &object_find_interface_handle); > + iter = icmap_iter_init("totem.interface."); > + while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) { > + res = sscanf(iter_key, "totem.interface.%[^.].%s", ringnumber_key, tmp_key); > + if (res != 2) { > + continue; > + } > > - while (objdb->object_find_next ( > - object_find_interface_handle, > - &object_interface_handle) == 0) { > + if (strcmp(tmp_key, "bindnetaddr") != 0) { > + continue; > + } > > member_count = 0; > > - objdb_get_int (objdb, object_interface_handle, "ringnumber", &ringnumber); > + ringnumber = atoi(ringnumber_key); > + > + /* > + * Get the bind net address > + */ > + if (icmap_get_string(iter_key, &str) == CS_OK) { > + res = totemip_parse (&totem_config->interfaces[ringnumber].bindnet, str, > + totem_config->interfaces[ringnumber].mcast_addr.family); > + free(str); > + } > > /* > * Get interface multicast address > */ > - if (!objdb_get_string (objdb, object_interface_handle, "mcastaddr", &str)) { > + snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastaddr", ringnumber); > + if (icmap_get_string(tmp_key, &str) == CS_OK) { > res = totemip_parse (&totem_config->interfaces[ringnumber].mcast_addr, str, 0); > + free(str); > } > + > totem_config->broadcast_use = 0; > - if (!objdb_get_string (objdb, object_interface_handle, "broadcast", &str)) { > + snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.broadcast", ringnumber); > + if (icmap_get_string(tmp_key, &str) == CS_OK) { > if (strcmp (str, "yes") == 0) { > totem_config->broadcast_use = 1; > totemip_parse ( > &totem_config->interfaces[ringnumber].mcast_addr, > "255.255.255.255", 0); > } > + free(str); > } > > /* > * Get mcast port > */ > - if (!objdb_get_string (objdb, object_interface_handle, "mcastport", &str)) { > - totem_config->interfaces[ringnumber].ip_port = atoi (str); > - } > - > - /* > - * Get the bind net address > - */ > - if (!objdb_get_string (objdb, object_interface_handle, "bindnetaddr", &str)) { > - > - res = totemip_parse (&totem_config->interfaces[ringnumber].bindnet, str, > - totem_config->interfaces[ringnumber].mcast_addr.family); > - } > + snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastport", ringnumber); > + icmap_get_uint16(tmp_key, &totem_config->interfaces[ringnumber].ip_port); > > /* > * Get the TTL > */ > totem_config->interfaces[ringnumber].ttl = 1; > - if (!objdb_get_string (objdb, object_interface_handle, "ttl", &str)) { > - totem_config->interfaces[ringnumber].ttl = atoi (str); > - } > > - objdb->object_find_create ( > - object_interface_handle, > - "member", > - strlen ("member"), > - &object_find_member_handle); > + snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.ttl", ringnumber); > > - while (objdb->object_find_next ( > - object_find_member_handle, > - &object_member_handle) == 0) { > + if (icmap_get_uint8(tmp_key, &u8) == CS_OK) { > + totem_config->interfaces[ringnumber].ttl = u8; > + } > > - if (!objdb_get_string (objdb, object_member_handle, "memberaddr", &str)) { > - res = totemip_parse (&totem_config->interfaces[ringnumber].member_list[member_count++], str, 0); > + snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.member.", ringnumber); > + member_iter = icmap_iter_init(tmp_key); > + while ((member_iter_key = icmap_iter_next(member_iter, NULL, NULL)) != NULL) { > + if (icmap_get_string(member_iter_key, &str) == CS_OK) { > + res = totemip_parse (&totem_config->interfaces[ringnumber].member_list[member_count++], > + str, 0); > } > - > } > + > totem_config->interfaces[ringnumber].member_count = member_count; > totem_config->interface_count++; > - objdb->object_find_destroy (object_find_member_handle); > } > > - objdb->object_find_destroy (object_find_interface_handle); > - > - add_totem_config_notification(objdb, totem_config, object_totem_handle); > - > totem_config->transport_number = TOTEM_TRANSPORT_UDP; > - (void)objdb_get_string (objdb, object_totem_handle, "transport", &transport_type); > - > - if (transport_type) { > - if (strcmp (transport_type, "udpu") == 0) { > + if (icmap_get_string("totem.transport", &str) == CS_OK) { > + if (strcmp (str, "udpu") == 0) { > totem_config->transport_number = TOTEM_TRANSPORT_UDPU; > } > - } > - if (transport_type) { > - if (strcmp (transport_type, "iba") == 0) { > + > + if (strcmp (str, "iba") == 0) { > totem_config->transport_number = TOTEM_TRANSPORT_RDMA; > } > + free(str); > } > > + add_totem_config_notification(totem_config); > + > return 0; > } > > @@ -804,14 +681,13 @@ parse_error: > } > > int totem_config_keyread ( > - struct objdb_iface_ver0 *objdb, > struct totem_config *totem_config, > const char **error_string) > { > int got_key = 0; > - const char *key_location = NULL; > - hdb_handle_t object_totem_handle; > + char *key_location = NULL; > int res; > + size_t key_len; > > memset (totem_config->private_key, 0, 128); > totem_config->private_key_len = 128; > @@ -820,34 +696,27 @@ int totem_config_keyread ( > return (0); > } > > - res = totem_handle_find (objdb, &object_totem_handle); > - if (res == -1) { > - return (-1); > - } > - /* objdb may store the location of the key file */ > - if (!objdb_get_string (objdb,object_totem_handle, "keyfile", &key_location) > - && key_location) { > + /* cmap may store the location of the key file */ > + if (icmap_get_string("totem.keyfile", &key_location) == CS_OK) { > res = read_keyfile(key_location, totem_config, error_string); > + free(key_location); > if (res) { > goto key_error; > } > got_key = 1; > - } else { /* Or the key itself may be in the objdb */ > - char *key = NULL; > - size_t key_len; > - res = objdb->object_key_get (object_totem_handle, > - "key", > - strlen ("key"), > - (void *)&key, > - &key_len); > - > - if (res == 0 && key) { > + } else { /* Or the key itself may be in the cmap */ > + if (icmap_get("totem.key", NULL, &key_len, NULL) == CS_OK) { > if (key_len > sizeof (totem_config->private_key)) { > + sprintf(error_string_response, "key is too long"); > + goto key_error; > + } > + if (icmap_get("totem.key", totem_config->private_key, &key_len, NULL) == CS_OK) { > + totem_config->private_key_len = key_len; > + got_key = 1; > + } else { > + sprintf(error_string_response, "can't store private key"); > goto key_error; > } > - memcpy(totem_config->private_key, key, key_len); > - totem_config->private_key_len = key_len; > - got_key = 1; > } > } > > @@ -870,100 +739,23 @@ key_error: > > } > > -static void totem_key_change_notify(object_change_type_t change_type, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *object_name_pt, size_t object_name_len, > - const void *key_name_pt, size_t key_len, > - const void *key_value_pt, size_t key_value_len, > - void *priv_data_pt) > +static void totem_change_notify( > + int32_t event, > + const char *key_name, > + struct icmap_notify_value new_val, > + struct icmap_notify_value old_val, > + void *user_data) > { > - struct totem_config *totem_config = priv_data_pt; > - > - if (memcmp(object_name_pt, "totem", object_name_len) == 0) > - totem_volatile_config_read(global_objdb, > - totem_config, > - object_handle); // CHECK > -} > - > -static void totem_objdb_reload_notify(objdb_reload_notify_type_t type, int flush, > - void *priv_data_pt) > -{ > - struct totem_config *totem_config = priv_data_pt; > - hdb_handle_t totem_object_handle; > - > - if (totem_config == NULL) > - return; > - > - /* > - * A new totem {} key might exist, cancel the > - * existing notification at the start of reload, > - * and start a new one on the new object when > - * it's all settled. > - */ > - > - if (type == OBJDB_RELOAD_NOTIFY_START) { > - global_objdb->object_track_stop( > - totem_key_change_notify, > - NULL, > - NULL, > - NULL, > - totem_config); > - } > - > - if (type == OBJDB_RELOAD_NOTIFY_END || > - type == OBJDB_RELOAD_NOTIFY_FAILED) { > - > - > - if (!totem_handle_find(global_objdb, > - &totem_object_handle)) { > - > - global_objdb->object_track_start(totem_object_handle, > - 1, > - totem_key_change_notify, > - NULL, // object_create_notify, > - NULL, // object_destroy_notify, > - NULL, // object_reload_notify > - totem_config); // priv_data > - /* > - * Reload the configuration > - */ > - totem_volatile_config_read(global_objdb, > - totem_config, > - totem_object_handle); > - > - } > - else { > - log_printf(LOGSYS_LEVEL_ERROR, "totem objdb tracking stopped, cannot find totem{} handle on objdb\n"); > - } > - } > + totem_volatile_config_read((struct totem_config *)user_data); > } > > - > -static void add_totem_config_notification( > - struct objdb_iface_ver0 *objdb, > - struct totem_config *totem_config, > - hdb_handle_t totem_object_handle) > +static void add_totem_config_notification(struct totem_config *totem_config) > { > + icmap_track_t icmap_track; > > - global_objdb = objdb; > - objdb->object_track_start(totem_object_handle, > - 1, > - totem_key_change_notify, > - NULL, // object_create_notify, > - NULL, // object_destroy_notify, > - NULL, // object_reload_notify > - totem_config); // priv_data > - > - /* > - * Reload notify must be on the parent object > - */ > - objdb->object_track_start(OBJECT_PARENT_HANDLE, > - 1, > - NULL, // key_change_notify, > - NULL, // object_create_notify, > - NULL, // object_destroy_notify, > - totem_objdb_reload_notify, // object_reload_notify > - totem_config); // priv_data > - > + icmap_track_add("totem.", > + ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY | ICMAP_TRACK_PREFIX, > + totem_change_notify, > + totem_config, > + &icmap_track); > } > diff --git a/exec/totemconfig.h b/exec/totemconfig.h > index 9901b8c..cee52b7 100644 > --- a/exec/totemconfig.h > +++ b/exec/totemconfig.h > @@ -40,12 +40,10 @@ > #include <corosync/list.h> > #include <qb/qbloop.h> > #include <corosync/totem/totempg.h> > -#include <corosync/engine/objdb.h> > > #include "totemsrp.h" > > extern int totem_config_read ( > - struct objdb_iface_ver0 *objdb, > struct totem_config *totem_config, > const char **error_string); > > @@ -54,7 +52,6 @@ extern int totem_config_validate ( > const char **error_string); > > int totem_config_keyread ( > - struct objdb_iface_ver0 *objdb, > struct totem_config *totem_config, > const char **error_string); > > diff --git a/exec/vsf_quorum.c b/exec/vsf_quorum.c > index ede7786..53ad331 100644 > --- a/exec/vsf_quorum.c > +++ b/exec/vsf_quorum.c > @@ -67,6 +67,7 @@ > #include <corosync/engine/coroapi.h> > #include <corosync/engine/logsys.h> > #include <corosync/engine/quorum.h> > +#include <corosync/engine/icmap.h> > > LOGSYS_DECLARE_SUBSYS ("QUORUM"); > > @@ -278,8 +279,6 @@ static struct quorum_callin_functions callins = { > > static int quorum_exec_init_fn (struct corosync_api_v1 *api) > { > - hdb_handle_t find_handle; > - hdb_handle_t quorum_handle = 0; > hdb_handle_t q_handle; > char *quorum_module; > int res; > @@ -300,37 +299,28 @@ static int quorum_exec_init_fn (struct corosync_api_v1 *api) > /* > * Look for a quorum provider > */ > - api->object_find_create(OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &find_handle); > - api->object_find_next(find_handle, &quorum_handle); > - api->object_find_destroy(find_handle); > - > - if (quorum_handle) { > - if ( !(res = api->object_key_get(quorum_handle, > - "provider", > - strlen("provider"), > - (void *)&quorum_module, > - NULL))) { > - > - res = lcr_ifact_reference ( > - &q_handle, > - quorum_module, > - 0, > - &quorum_iface_p, > - 0); > - > - if (res == -1) { > - log_printf (LOGSYS_LEVEL_NOTICE, > - "Couldn't load quorum provider %s\n", > - quorum_module); > - return (-1); > - } > - > + if (icmap_get_string("quorum.provider", &quorum_module) == CS_OK) { > + res = lcr_ifact_reference ( > + &q_handle, > + quorum_module, > + 0, > + &quorum_iface_p, > + 0); > + > + if (res == -1) { > log_printf (LOGSYS_LEVEL_NOTICE, > - "Using quorum provider %s\n", quorum_module); > - > - quorum_iface = (struct quorum_services_api_ver1 *)quorum_iface_p; > - quorum_iface->init (api, quorum_api_set_quorum); > + "Couldn't load quorum provider %s\n", > + quorum_module); > + free(quorum_module); > + return (-1); > } > + > + log_printf (LOGSYS_LEVEL_NOTICE, > + "Using quorum provider %s\n", quorum_module); > + > + quorum_iface = (struct quorum_services_api_ver1 *)quorum_iface_p; > + quorum_iface->init (api, quorum_api_set_quorum); > + free(quorum_module); > } > if (!quorum_iface) { > /* > diff --git a/include/corosync/engine/config.h b/include/corosync/engine/config.h > index e7c8ded..e6f7686 100644 > --- a/include/corosync/engine/config.h > +++ b/include/corosync/engine/config.h > @@ -36,9 +36,9 @@ > #define CONFIG_H_DEFINED > > struct config_iface_ver0 { > - int (*config_readconfig) (struct objdb_iface_ver0 *objdb, const char **error_string); > - int (*config_writeconfig) (struct objdb_iface_ver0 *objdb, const char **error_string); > - int (*config_reloadconfig) (struct objdb_iface_ver0 *objdb, int flush, const char **error_string); > + int (*config_readconfig) (const char **error_string); > + int (*config_writeconfig) (const char **error_string); > + int (*config_reloadconfig) (int flush, const char **error_string); > }; > > > diff --git a/lib/sa-confdb.c b/lib/sa-confdb.c > index bd97234..bf7bc3e 100644 > --- a/lib/sa-confdb.c > +++ b/lib/sa-confdb.c > @@ -96,7 +96,7 @@ static int load_config(void) > hdb_handle_t config_version = 0; > void *config_p; > struct config_iface_ver0 *config; > - const char *error_string; > +// const char *error_string; > char *strtok_savept; > > /* User's bootstrap config service */ > @@ -127,7 +127,7 @@ static int load_config(void) > return -1; > } > > - res = config->config_readconfig(objdb, &error_string); > +// res = config->config_readconfig(objdb, &error_string); > if (res == -1) { > return -1; > } _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss