Skip to content

Commit

Permalink
cachedb_cassandra: check if counters table exists before using it
Browse files Browse the repository at this point in the history
(cherry picked from commit a81860e)
  • Loading branch information
rvlad-patrascu committed Sep 4, 2018
1 parent 5968346 commit c749b1b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/cachedb_cassandra/cachedb_cassandra_dbase.c
Expand Up @@ -543,6 +543,11 @@ static int basic_get_counter(cachedb_con *con, str *attr, int *val)

cass_con = (cassandra_con *)con->data;

if (!cass_con->cnt_table.s) {
LM_ERR("No counters table defined\n");
return -1;
}

/* build select query */
cql_buf_len = snprintf(cql_buf, CQL_BUF_LEN, "SELECT \"%s\" FROM \"%.*s\".\"%.*s\""
" WHERE \"%s\" = ?", CASS_OSS_VAL_COL, cass_con->keyspace.len, cass_con->keyspace.s,
Expand Down Expand Up @@ -626,6 +631,11 @@ static int basic_update_counter(cachedb_con *con, str *attr, int val, char op,

cass_con = (cassandra_con *)con->data;

if (!cass_con->cnt_table.s) {
LM_ERR("No counters table defined\n");
return -1;
}

/* build update query */
cql_buf_len = snprintf(cql_buf, CQL_BUF_LEN, "UPDATE \"%.*s\".\"%.*s\" SET "
"\"%s\" = \"%s\" %c ? WHERE \"%s\" = ?", cass_con->keyspace.len, cass_con->keyspace.s,
Expand Down

0 comments on commit c749b1b

Please sign in to comment.