static void s_once_proc(void) { lagopus_result_t r; if ((r = lagopus_hashmap_create(&s_tbl, LAGOPUS_HASHMAP_TYPE_STRING, NULL)) != LAGOPUS_RESULT_OK) { lagopus_perror(r); lagopus_exit_fatal("can't initialize an object table.\n"); } if ((r = datastore_register_table(MY_COMMAND_NAME, &s_tbl, s_update, NULL, NULL, NULL, NULL, NULL)) != LAGOPUS_RESULT_OK) { lagopus_perror(r); lagopus_exit_fatal("can't register an object table for \"%s\".\n", MY_COMMAND_NAME); } if ((r = datastore_create_interp(&s_interp)) != LAGOPUS_RESULT_OK) { lagopus_perror(r); lagopus_exit_fatal("can't create the datastore interpretor.\n"); } if ((r = datastore_interp_register_command(&s_interp, NULL, MY_COMMAND_NAME, s_parse)) != LAGOPUS_RESULT_OK) { lagopus_perror(r); lagopus_exit_fatal("can't register an object command \"%s\".\n", MY_COMMAND_NAME); } (void)pthread_atfork(NULL, NULL, s_child_at_fork); }
static inline lagopus_result_t initialize_internal(void) { lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES; datastore_interp_t s_interp = datastore_get_master_interp(); /* create hashmap for sub cmds. */ if ((ret = lagopus_hashmap_create(&sub_cmd_table, LAGOPUS_HASHMAP_TYPE_STRING, NULL)) != LAGOPUS_RESULT_OK) { lagopus_perror(ret); goto done; } if (((ret = sub_cmd_add(ADD_SUB_CMD, add_sub_cmd_parse, &sub_cmd_table)) != LAGOPUS_RESULT_OK) || ((ret = sub_cmd_add(MOD_SUB_CMD, mod_sub_cmd_parse, &sub_cmd_table)) != LAGOPUS_RESULT_OK) || ((ret = sub_cmd_add(DEL_SUB_CMD, del_sub_cmd_parse, &sub_cmd_table)) != LAGOPUS_RESULT_OK)) { goto done; } /* create hashmap for sub cmds (not name). */ if ((ret = lagopus_hashmap_create(&sub_cmd_not_name_table, LAGOPUS_HASHMAP_TYPE_STRING, NULL)) != LAGOPUS_RESULT_OK) { lagopus_perror(ret); goto done; } if (((ret = sub_cmd_add(CONFIG_SUB_CMD, config_sub_cmd_parse, &sub_cmd_not_name_table)) != LAGOPUS_RESULT_OK)) { goto done; } /* create hashmap for dump opts. */ if ((ret = lagopus_hashmap_create(&dump_opt_table, LAGOPUS_HASHMAP_TYPE_STRING, NULL)) != LAGOPUS_RESULT_OK) { lagopus_perror(ret); goto done; } if (((ret = opt_add(opt_strs[OPT_TABLE_ID], table_id_opt_parse, &dump_opt_table)) != LAGOPUS_RESULT_OK) || ((ret = opt_add(opt_strs[OPT_WITH_STATS], with_stats_opt_parse, &dump_opt_table)) != LAGOPUS_RESULT_OK)) { goto done; } /* create hashmap for config opts. */ if ((ret = lagopus_hashmap_create(&config_opt_table, LAGOPUS_HASHMAP_TYPE_STRING, NULL)) != LAGOPUS_RESULT_OK) { lagopus_perror(ret); goto done; } if ((ret = opt_add(opt_strs[OPT_TMP_DIR], tmp_dir_opt_parse, &config_opt_table)) != LAGOPUS_RESULT_OK) { goto done; } if ((ret = flow_cmd_mod_initialize()) != LAGOPUS_RESULT_OK) { goto done; } if ((ret = datastore_interp_register_command(&s_interp, CONFIGURATOR_NAME, CMD_NAME, flow_cmd_parse)) != LAGOPUS_RESULT_OK) { lagopus_perror(ret); goto done; } if ((ret = flow_cmd_dump_initialize()) != LAGOPUS_RESULT_OK) { goto done; } done: return ret; }