Skip to content

Commit

Permalink
mqueue: fix debug level for debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiusas committed Feb 7, 2024
1 parent 5ff1df9 commit 1a38989
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 34 deletions.
13 changes: 4 additions & 9 deletions modules/mqueue/mqueue_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ int mq_head_add(str *name, int msize, int addmode)
mq_pv_t *mp = NULL;
int len;

//FIXME:
//if(!shm_initialized()) {
// LM_ERR("shm not initialized - cannot define mqueue now\n");
// return 0;
//}

mh = _mq_head_list;
while(mh != NULL) {
if(name->len == mh->name.len
Expand Down Expand Up @@ -411,7 +405,7 @@ int pv_get_mqk(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
return -1;
}

LM_NOTICE("Getting key from [%.*s]\n", res->rs.len, res->rs.s);
LM_DBG("Getting key from [%.*s]\n", res->rs.len, res->rs.s);
if(mq_head_get(&res->rs) == NULL) {
LM_ERR("mqueue not found: %.*s\n", res->rs.len, res->rs.s);
return -1;
Expand Down Expand Up @@ -474,7 +468,7 @@ int pv_get_mqv(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
return -1;
}

LM_NOTICE("Getting val from [%.*s]\n", res->rs.len, res->rs.s);
LM_DBG("Getting val from [%.*s]\n", res->rs.len, res->rs.s);
if(mq_head_get(&res->rs) == NULL) {
LM_ERR("mqueue not found: %.*s\n", res->rs.len, res->rs.s);
return -1;
Expand All @@ -501,7 +495,7 @@ int pv_get_mq_size(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
return -1;
}

LM_NOTICE("Getting size of [%.*s]\n", res->rs.len, res->rs.s);
LM_DBG("Getting size of [%.*s]\n", res->rs.len, res->rs.s);
mqs = _mq_get_csize(&res->rs);

if(mqs < 0) {
Expand All @@ -511,6 +505,7 @@ int pv_get_mq_size(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)

return pv_get_sintval(msg, param, res, mqs);
}

/**
* Return head->csize for a given queue
*/
Expand Down
16 changes: 8 additions & 8 deletions modules/mqueue/mqueue_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ str mq_db_id_column = str_init("id");
*/
int mqueue_db_init_con(void)
{
LM_NOTICE("mqueue_db_url=[%.*s]\n", mqueue_db_url.len, mqueue_db_url.s);
LM_DBG("mqueue_db_url=[%.*s]\n", mqueue_db_url.len, mqueue_db_url.s);
if(mqueue_db_url.len <= 0) {
LM_ERR("failed to connect to the database, no db url\n");
return -1;
Expand Down Expand Up @@ -68,7 +68,7 @@ int mqueue_db_open_con(void)
LM_ERR("failed to connect to the database\n");
return -1;
}
LM_NOTICE("database connection opened successfully\n");
LM_DBG("database connection opened successfully\n");
return 0;
}
return 0;
Expand Down Expand Up @@ -125,7 +125,7 @@ int mqueue_db_load_queue(str *name)
} else {
if(RES_ROW_N(db_res) == 0) {
mq_dbf.free_result(mqueue_db_con, db_res);
LM_NOTICE("Nothing to be loaded in queue\n");
LM_DBG("Nothing to be loaded in queue\n");
mqueue_db_close_con();
return 0;
}
Expand Down Expand Up @@ -228,7 +228,7 @@ int mqueue_db_load_queue(str *name)
goto error;
}
cnt++;
LM_NOTICE("adding item[%d] key[%.*s] value[%.*s]\n", cnt, key.len,
LM_DBG("adding item[%d] key[%.*s] value[%.*s]\n", cnt, key.len,
key.s, val.len, val.s);
mq_item_add(name, &key, &val);
}
Expand All @@ -250,7 +250,7 @@ int mqueue_db_load_queue(str *name)
goto error;
}

LM_NOTICE("loaded %d values in queue\n", cnt);
LM_DBG("loaded %d values in queue\n", cnt);
mqueue_db_close_con();
return 0;
error:
Expand Down Expand Up @@ -296,7 +296,7 @@ int mqueue_db_save_queue(str *name)
str *val = NULL;
key = get_mqk(name);
val = get_mqv(name);
LM_NOTICE("inserting mqueue[%.*s] name[%.*s] value[%.*s]\n", name->len,
LM_DBG("inserting mqueue[%.*s] name[%.*s] value[%.*s]\n", name->len,
name->s, key->len, key->s, val->len, val->s);
db_vals[0].type = DB_STR;
db_vals[0].nul = 0;
Expand All @@ -306,11 +306,11 @@ int mqueue_db_save_queue(str *name)
db_vals[1].nul = 0;
db_vals[1].val.str_val.s = val->s;
db_vals[1].val.str_val.len = val->len;
LM_NOTICE("mq_dbf.insert()\n");
LM_DBG("mq_dbf.insert()\n");
if(mq_dbf.insert(mqueue_db_con, db_cols, db_vals, ncols) < 0) {
LM_ERR("failed to store key [%.*s] val [%.*s]\n", key->len, key->s,
val->len, val->s);
LM_NOTICE("done mq_dbf.insert()\n");
LM_DBG("done mq_dbf.insert()\n");
}
}

Expand Down
19 changes: 2 additions & 17 deletions modules/mqueue/mqueue_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int mod_init(void)
{
mq_head_t *mh = NULL;

LM_NOTICE("initializing...\n");
LM_DBG("initializing...\n");

init_db_url( mqueue_db_url , 1 /*can be null*/);

Expand All @@ -168,7 +168,7 @@ static int mod_init(void)
mh = _mq_head_list;
while(mh != NULL) {
if (mh->dbmode == 1 || mh->dbmode == 2) {
LM_NOTICE("queue=[%.*s]\n", mh->name.len, mh->name.s);
LM_DBG("queue=[%.*s]\n", mh->name.len, mh->name.s);
if(mqueue_db_load_queue(&mh->name) < 0) {
LM_ERR("error loading mqueue: %.*s from DB\n", mh->name.len, mh->name.s);
return -1;
Expand All @@ -178,13 +178,11 @@ static int mod_init(void)
}
}


return 0;
}

static int child_init(int rank)
{
//FIXME:
return 0;
}

Expand Down Expand Up @@ -247,12 +245,6 @@ int mq_param(modparam_t type, void *val)
if(val == NULL)
return -1;

//FIXME:
//if(!shm_initialized()) {
// LM_ERR("shm not initialized - cannot define mqueue now\n");
// return 0;
//}

mqs.s = (char *)val;
mqs.len = strlen(mqs.s);
if(mqs.s[mqs.len - 1] == ';')
Expand Down Expand Up @@ -289,13 +281,6 @@ int mq_param(modparam_t type, void *val)
}
LM_INFO("mqueue param: [%.*s|%d|%d|%d]\n", qname.len, qname.s, dbmode,
addmode, msize);
//if(dbmode == 1 || dbmode == 2) {
// if(mqueue_db_load_queue(&qname) < 0) {
// LM_ERR("error loading mqueue: %.*s from DB\n", qname.len, qname.s);
// free_params(params_list);
// return -1;
// }
//}
mq_set_dbmode(&qname, dbmode);
free_params(params_list);
return 0;
Expand Down

0 comments on commit 1a38989

Please sign in to comment.