Skip to content

Commit

Permalink
tcp_mgm: Fix startup issue; Fix "while" fallthrough and bad logs
Browse files Browse the repository at this point in the history
  • Loading branch information
liviuchircu committed Jul 14, 2022
1 parent f7b71ac commit b83549e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions modules/tcp_mgm/tcp_db.c
Expand Up @@ -185,6 +185,7 @@ int db_row_decode(db_row_t *row, db_col_t *cols,
default:
goto error_type;
}
break;

case DB_BIGINT:
switch (val->type) {
Expand Down
5 changes: 2 additions & 3 deletions modules/tcp_mgm/tcp_db.h
Expand Up @@ -43,14 +43,12 @@ extern db_col_t tcp_mgm_cols[];
extern db_con_t *db_hdl;
extern db_func_t db;

#define NO_STR_VALS 4

#define TCPCOL_PROTO 0
#define TCPCOL_REMOTE_ADDR 1
#define TCPCOL_LOCAL_ADDR 2
#define TCPCOL_ATTRS 3

#define NO_INT_VALS 15
#define NO_STR_VALS 4

#define TCPCOL_ID 0
#define TCPCOL_REMOTE_PORT 1
Expand All @@ -67,6 +65,7 @@ extern db_func_t db;
#define TCPCOL_KEEPCOUNT 12
#define TCPCOL_KEEPIDLE 13
#define TCPCOL_KEEPINTERVAL 14
#define NO_INT_VALS 15

#define NO_DB_COLS (NO_STR_VALS + NO_INT_VALS)

Expand Down
4 changes: 2 additions & 2 deletions modules/tcp_mgm/tcp_mgm.c
Expand Up @@ -117,13 +117,13 @@ struct module_exports exports = {
static int mod_init(void)
{
/* initialize the data cache */
if (!tcp_path_init()) {
if (tcp_path_init() != 0) {
LM_ERR("failed to init internal structures\n");
return -1;
}

/* cache all DB data straight away */
if (!tcp_db_init()) {
if (tcp_db_init() != 0) {
LM_ERR("failed to initialize and/or load DB data\n");
return -1;
}
Expand Down
12 changes: 8 additions & 4 deletions modules/tcp_mgm/tcp_path.c
Expand Up @@ -262,12 +262,16 @@ int tcp_store_path(int *int_vals, char **str_vals, struct tcp_path *path)
LM_INFO("----------- TCP Path [%d] -------------\n", int_vals[TCPCOL_ID]);
LM_INFO("priority: %d\n", path->priority);
LM_INFO("proto: %d\n", path->proto);
LM_INFO("remote: %s:%u | ANY: %d\n", ip_addr2a(&path->remote_addr.ip),
LM_INFO("remote: %s:%u | ANY: %d\n",
path->remote_any ? "NULL" : ip_addr2a(&path->remote_addr.ip),
path->remote_port, path->remote_any);
LM_INFO("remote_prefix: %s\n", ip_addr2a(&path->remote_addr.mask));
LM_INFO("local: %s:%u\n | ANY: %d", ip_addr2a(&path->local_addr.ip),
LM_INFO("remote_prefix: %s\n",
path->remote_any ? "NULL" : ip_addr2a(&path->remote_addr.mask));
LM_INFO("local: %s:%u | ANY: %d\n",
path->local_any ? "NULL" : ip_addr2a(&path->local_addr.ip),
path->local_port, path->local_any);
LM_INFO("local_prefix: %s\n", ip_addr2a(&path->local_addr.mask));
LM_INFO("local_prefix: %s\n",
path->local_any ? "NULL" : ip_addr2a(&path->local_addr.mask));
LM_INFO(" %d %d %d\n", path->prof.connect_timeout,
path->prof.con_lifetime, path->prof.msg_read_timeout);
LM_INFO(" %d %d %d %d\n", path->prof.send_threshold,
Expand Down
4 changes: 2 additions & 2 deletions modules/tcp_mgm/tcp_path.h
Expand Up @@ -34,11 +34,11 @@ struct tcp_path {
enum sip_protos proto;

struct net remote_addr;
char remote_any:1;
char remote_any;
unsigned short remote_port;

struct net local_addr;
char local_any:1;
char local_any;
unsigned short local_port;

int priority;
Expand Down

0 comments on commit b83549e

Please sign in to comment.