Skip to content

Commit

Permalink
db_berkeley: port MI commands to jsonrpc
Browse files Browse the repository at this point in the history
  • Loading branch information
rvlad-patrascu committed Jan 10, 2019
1 parent e8d213f commit 6418985
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
22 changes: 8 additions & 14 deletions modules/db_berkeley/bdb_mi.c
Expand Up @@ -35,27 +35,21 @@
* MI function to reload db table or env
* expects 1 node: the tablename or dbenv name to reload
*/
struct mi_root* mi_bdb_reload(struct mi_root *cmd, void *param)
mi_response_t *mi_bdb_reload(const mi_params_t *params,
struct mi_handler *async_hdl)
{
struct mi_node *node;
str *db_path;
str db_path;

node = cmd->node.kids;
if (node && node->next)
return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
if (get_mi_string_param(params, "table_path", &db_path.s, &db_path.len) < 0)
return init_mi_param_error();

db_path = &node->value;

if (!db_path || db_path->len == 0)
return init_mi_tree( 400, "bdb_reload missing db arg", 21);

if (bdb_reload(db_path->s) == 0)
if (bdb_reload(db_path.s) == 0)
{
return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
return init_mi_result_ok();
}
else
{
return init_mi_tree( 500, "db_berkeley Reload Failed", 26);
return init_mi_error(500, MI_SSTR("db_berkeley Reload Failed"));
}
}

3 changes: 2 additions & 1 deletion modules/db_berkeley/bdb_mi.h
Expand Up @@ -28,7 +28,8 @@

#define MI_BDB_RELOAD "bdb_reload"

struct mi_root* mi_bdb_reload(struct mi_root *cmd, void *param);
mi_response_t *mi_bdb_reload(const mi_params_t *params,
struct mi_handler *async_hdl);


#endif
7 changes: 5 additions & 2 deletions modules/db_berkeley/db_berkeley.c
Expand Up @@ -86,8 +86,11 @@ static param_export_t params[] = {
* Exported MI functions
*/
static mi_export_t mi_cmds[] = {
{ MI_BDB_RELOAD, 0, mi_bdb_reload, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0}
{ MI_BDB_RELOAD, 0, 0, 0, {
{mi_bdb_reload, {"table_path", 0}},
{EMPTY_MI_RECIPE}}
},
{EMPTY_MI_EXPORT}
};

struct module_exports exports = {
Expand Down
2 changes: 1 addition & 1 deletion modules/db_berkeley/doc/db_berkeley_admin.xml
Expand Up @@ -143,7 +143,7 @@ modparam("db_berkeley", "journal_roll_interval", 3600)
<para>Parameters:</para>
<itemizedlist>
<listitem><para>
<emphasis>table/path</emphasis> - to reload a particular table
<emphasis>table_path</emphasis> - to reload a particular table
provide the tablename as the arguement; to reload
all tables provide the db_path to the db files. The path can be found
in opensipsctlrc DB_PATH variable.
Expand Down

0 comments on commit 6418985

Please sign in to comment.