Re: Throughput enhancements
"Alan Milligan" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
This patch is against yesterday's trunk. Please apply it ASAP. Best regards, Alan Hi, I have some patches against 1.4.3 that enhance throughputs. Throughput is reported in the statuses, and there is a new bearerbox admin function to dynamically set the throughput for any specified smsc connection (it does of course affect both the receive and transmit though). Upon restart, throughput is as per kannel.conf. I'd like to get these into the official 1.5.x Kannel release. What is the best way to kick this off? Alan
kannel-1.5.0-throughput.patch
(application/octet-stream, 5.9 KB)
--- gw/bb_http.c.orig 2010-11-24 16:48:43.000000000 +1100
+++ gw/bb_http.c 2010-11-26 13:40:08.416775871 +1100
@@ -320,6 +320,31 @@
return octstr_create("SMSC id not given");
}
+static Octstr *httpd_throughput_smsc(List *cgivars, int status_type)
+{
+ Octstr *reply;
+ Octstr *smsc;
+ Octstr *throughput;
+ double tp = 0;
+ if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply;
+ if ((reply = httpd_check_status())!= NULL) return reply;
+
+ /* check if the smsc id is given */
+ smsc = http_cgi_variable(cgivars, "smsc");
+ throughput = http_cgi_variable(cgivars, "throughput");
+
+ if (!smsc) return octstr_create("SMSC id not given");
+ if (!throughput) return octstr_create("throughput not given");
+
+ if (octstr_parse_double(&tp, throughput, 0) == -1)
+ return octstr_create("throughput not parsable");
+
+ if (bb_throughput_smsc(smsc, tp) == -1)
+ return octstr_format("Could not change throughput for smsc-id `%s'", octstr_get_cstr(smsc));
+ else
+ return octstr_format("SMSC `%s' throughput changed", octstr_get_cstr(smsc));
+}
+
static Octstr *httpd_reload_lists(List *cgivars, int status_type)
{
Octstr *reply;
@@ -351,6 +376,7 @@
{ "add-smsc", httpd_add_smsc },
{ "remove-smsc", httpd_remove_smsc },
{ "reload-lists", httpd_reload_lists },
+ { "throughput-smsc", httpd_throughput_smsc },
{ NULL , NULL } /* terminate list */
};
--- gw/bb_smscconn.c.orig 2009-01-13 03:46:56.000000000 +1100
+++ gw/bb_smscconn.c 2010-09-24 11:17:59.618937112 +1000
@@ -787,6 +787,30 @@
return 0;
}
+int smsc2_throughput_smsc(Octstr *id, double throughput)
+{
+ SMSCConn *conn;
+ long i = -1;
+
+ if (!smsc_running)
+ return -1;
+
+ gw_rwlock_rdlock(&smsc_list_lock);
+ /* find the specific smsc via id */
+ while((i = smsc2_find(id, ++i)) != -1) {
+ conn = gwlist_get(smsc_list, i);
+ if (conn == NULL) {
+ info(0, "HTTP: Could not throttle null smsc-id `%s'",
+ octstr_get_cstr(id));
+ } else {
+ info(0,"HTTP: Setting throughput on smsc-id `%s'", octstr_get_cstr(id));
+ smscconn_setthroughput(conn, throughput);
+ }
+ }
+ gw_rwlock_unlock(&smsc_list_lock);
+ return 0;
+}
+
void smsc2_resume(void)
{
SMSCConn *conn;
@@ -905,6 +929,7 @@
StatusInfo info;
const Octstr *conn_id = NULL;
const Octstr *conn_name = NULL;
+ const Octstr *conn_throughput = NULL;
if ((lb = bb_status_linebreak(status_type)) == NULL)
return octstr_create("Un-supported format");
@@ -940,6 +965,7 @@
conn_id = conn ? smscconn_id(conn) : octstr_imm("unknown");
conn_id = conn_id ? conn_id : octstr_imm("unknown");
conn_name = conn ? smscconn_name(conn) : octstr_imm("unknown");
+ conn_throughput = conn ? octstr_format("%0.2f", smscconn_throughput(conn)) : octstr_imm("unknown");
if (status_type == BBSTATUS_HTML) {
octstr_append_cstr(tmp, " <b>");
@@ -957,6 +983,9 @@
octstr_append_cstr(tmp, "<id>");
octstr_append(tmp, conn_id);
octstr_append_cstr(tmp, "</id>\n\t\t");
+ octstr_append_cstr(tmp, "<throughput>");
+ octstr_append(tmp, conn_throughput);
+ octstr_append_cstr(tmp, "</throughput>\n\t\t");
} else
octstr_append(tmp, conn_name);
--- gw/bearerbox.h.orig 2010-11-24 16:48:43.000000000 +1100
+++ gw/bearerbox.h 2010-11-26 13:44:20.515768559 +1100
@@ -174,7 +174,8 @@
int smsc2_restart_smsc(Octstr *id); /* re-start a specific smsc */
int smsc2_add_smsc(Octstr *id); /* add a new smsc */
int smsc2_remove_smsc(Octstr *id); /* remove a specific smsc */
-
+int smsc2_throughput_smsc(Octstr *id, double throughput); /* change throughput rate for a specific smsc */
+
int smsc2_reload_lists(void); /* reload blacklists */
@@ -217,6 +218,7 @@
int bb_add_smsc(Octstr *id);
int bb_remove_smsc(Octstr *id);
int bb_restart_smsc(Octstr *id);
+int bb_throughput_smsc(Octstr *id, double throughput);
int bb_reload_lists(void);
int bb_reload_smsc_groups(void);
--- gw/smscconn.c.orig 2009-01-13 03:46:56.000000000 +1100
+++ gw/smscconn.c 2010-09-24 11:21:22.672859372 +1000
@@ -62,6 +62,7 @@
* Kalle Marjola 2000 for project Kannel
*/
+#include <stdio.h>
#include <signal.h>
#include <time.h>
@@ -409,6 +410,18 @@
return conn->id;
}
+const Octstr *smscconn_throughput(SMSCConn *conn)
+{
+ gw_assert(conn != NULL);
+ return octstr_format("%d", conn->throughput);
+}
+
+void smscconn_setthroughput(SMSCConn *conn, double throughput)
+{
+ gw_assert(conn != NULL);
+ conn->throughput = throughput;
+ info(0, "Set throughput to %.3f for smsc id <%s>", conn->throughput, octstr_get_cstr(conn->id));
+}
int smscconn_usable(SMSCConn *conn, Msg *msg)
{
--- gw/bearerbox.c.orig 2010-09-24 11:48:42.798240538 +1000
+++ gw/bearerbox.c 2010-09-24 11:50:31.913232878 +1000
@@ -827,6 +827,11 @@
return bb_shutdown();
}
+int bb_throughput_smsc(Octstr *id, double throughput)
+{
+ return smsc2_throughput_smsc(id, throughput);
+}
+
#define append_status(r, s, f, x) { s = f(x); octstr_append(r, s); \
octstr_destroy(s); }
--- gw/smscconn.h.orig 2009-01-13 03:46:55.000000000 +1100
+++ gw/smscconn.h 2010-09-24 12:03:17.459983313 +1000
@@ -166,6 +166,12 @@
/* Return ID of the SMSC, as reference - caller may not free it! */
const Octstr *smscconn_id(SMSCConn *conn);
+/* Return throughput limit of the SMSC, as reference - caller may not free it! */
+const Octstr *smscconn_throughput(SMSCConn *conn);
+
+/* set throughput limit of the SMSC, as reference - caller may not free it! */
+void smscconn_setthroughput(SMSCConn *conn, double throughput);
+
/* Check if this SMSC Connection is usable as sender for given
* message. The bearerbox must then select the good SMSC for sending
* according to load levels and connected/disconnected status, this