Skip to content

Commit

Permalink
sql_cacher: fix data loading from previous commit
Browse files Browse the repository at this point in the history
Fix backporting of previous commit and do data loading in the child_init
function as the IPC framework doesn't have the ability to send RPC yet.
  • Loading branch information
rvlad-patrascu committed Jan 12, 2018
1 parent ca2f663 commit 7e47540
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions modules/sql_cacher/sql_cacher.c
Expand Up @@ -32,7 +32,6 @@
#include "../../locking.h"
#include "../../rw_locking.h"
#include "../../timer.h"
#include "../../ipc.h"
#include "sql_cacher.h"

static int mod_init(void);
Expand Down Expand Up @@ -1032,7 +1031,7 @@ static struct mi_root* mi_reload(struct mi_root *root, void *param)
return init_mi_tree(200, MI_SSTR(MI_OK_S));
}

static void full_caching_load(int sender, void *param)
static int full_caching_load(void)
{
cache_entry_t *c_entry;
db_handlers_t *db_hdls;
Expand All @@ -1056,7 +1055,7 @@ static void full_caching_load(int sender, void *param)
rld_vers_key.s = pkg_malloc(rld_vers_key.len);
if (!rld_vers_key.s) {
LM_ERR("No more pkg memory\n");
return;
return -1;
}
memcpy(rld_vers_key.s, c_entry->id.s, c_entry->id.len);
memcpy(rld_vers_key.s + c_entry->id.len, "_sql_cacher_reload_vers", 23);
Expand All @@ -1071,6 +1070,8 @@ static void full_caching_load(int sender, void *param)

pkg_free(rld_vers_key.s);
}

return 0;
}

static int mod_init(void)
Expand Down Expand Up @@ -1162,9 +1163,9 @@ static int child_init(int rank)
}
}

/* perform full caching load in the same process but after child_init is done */
if ((rank == 1) && ipc_send_rpc(process_no, full_caching_load, NULL) < 0) {
LM_ERR("Failed to RPC full caching load\n");
/* perform full caching load in the first child */
if (rank == 1 && full_caching_load() < 0) {
LM_ERR("Failed to do full caching load\n");
return -1;
}

Expand Down

0 comments on commit 7e47540

Please sign in to comment.