Module: kamailio
Branch: master
Commit: 86b4189c1335a2d1aa4414ab9d1a5b8a27a29e00
URL:
https://github.com/kamailio/kamailio/commit/86b4189c1335a2d1aa4414ab9d1a5b8…
Author: Olle E. Johansson <oej(a)edvina.net>
Committer: Olle E. Johansson <oej(a)edvina.net>
Date: 2022-01-03T15:41:10+01:00
db_cluster: Add RPC error messages and responses to dbcl_rpc_ddisable_connection
---
Modified: src/modules/db_cluster/db_cluster_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/86b4189c1335a2d1aa4414ab9d1a5b8…
Patch:
https://github.com/kamailio/kamailio/commit/86b4189c1335a2d1aa4414ab9d1a5b8…
---
diff --git a/src/modules/db_cluster/db_cluster_mod.c
b/src/modules/db_cluster/db_cluster_mod.c
index a2c28f88e5..d4aae0e123 100644
--- a/src/modules/db_cluster/db_cluster_mod.c
+++ b/src/modules/db_cluster/db_cluster_mod.c
@@ -250,6 +250,7 @@ static void dbcl_rpc_disable_connection(rpc_t *rpc, void *c)
if(cls==NULL)
{
LM_INFO("cluster not found [%.*s]\n", cluster.len, cluster.s);
+ rpc->fault(c, 500, "Cluster not found");
return;
}
@@ -258,16 +259,22 @@ static void dbcl_rpc_disable_connection(rpc_t *rpc, void *c)
if(con==NULL)
{
LM_INFO("connection not found [%.*s]\n", connection.len, connection.s);
+ rpc->fault(c, 500, "Cluster connection not found");
return;
}
if(con->sinfo==NULL)
+ rpc->fault(c, 500, "Cluster state info missing.");
return;
/* Overwrite the number of seconds if the connection is already disabled. */
if (con->sinfo->state & DBCL_CON_INACTIVE)
{
- dbcl_disable_con(con, seconds);
+ if(dbcl_disable_con(con, seconds) < 0) {
+ rpc->fault(c, 500, "Failed disabling cluster connection.");
+ return;
+ }
+ rpc->rpl_printf(c, "Ok. Cluster connection re-disabled.");
return;
}
@@ -277,8 +284,11 @@ static void dbcl_rpc_disable_connection(rpc_t *rpc, void *c)
return;
}
- dbcl_disable_con(con, seconds);
-
+ if(dbcl_disable_con(con, seconds) < 0) {
+ rpc->fault(c, 500, "Failed disabling cluster connection.");
+ return;
+ };
+ rpc->rpl_printf(c, "Ok. Cluster connection disabled.");
return;
}