From 104bab6b9217a0f86e68fc5f68ccb3be37b08ef1 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Jul 2012 12:33:13 -0500 Subject: [PATCH 1/5] tdd fix --- src/mod/applications/mod_spandsp/mod_spandsp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.c b/src/mod/applications/mod_spandsp/mod_spandsp.c index 25a180ef84..f79bea68ac 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp.c @@ -403,7 +403,7 @@ SWITCH_STANDARD_API(start_send_tdd_api) } - if (!(psession = switch_core_session_locate(cmd))) { + if (!(psession = switch_core_session_locate(puuid))) { stream->write_function(stream, "-ERR Cannot locate session\n"); goto end; } @@ -736,6 +736,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) SWITCH_ADD_API(api_interface, "uuid_send_tdd", "send tdd data to a uuid", start_send_tdd_api, " "); + switch_console_set_complete("add uuid_send_tdd ::console::list_uuid"); + if ((switch_event_bind(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL) != SWITCH_STATUS_SUCCESS)) { From 158f96651fa019bdba1a8eaa68c554b2b967525a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Jul 2012 11:04:10 -0500 Subject: [PATCH 2/5] add trailing newlines for lazy parsers --- src/mod/applications/mod_spandsp/mod_spandsp_dsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c index b01a4638a3..bec0172dea 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c @@ -121,7 +121,7 @@ static void put_text_msg(void *user_data, const uint8_t *msg, int len) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "tdd"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "TDD MESSAGE"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(pvt->session)); - switch_event_add_body(event, "%s", (char *)msg); + switch_event_add_body(event, "%s\n\n", (char *)msg); if (switch_core_session_get_partner(pvt->session, &other_session) == SWITCH_STATUS_SUCCESS) { From e06bf26e65a1088aff8dcb42578c4ec7b72a15cc Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Jul 2012 11:05:56 -0500 Subject: [PATCH 3/5] add tdd data also as a header for even lazier parsers --- src/mod/applications/mod_spandsp/mod_spandsp_dsp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c index bec0172dea..a3439ed612 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c @@ -120,6 +120,7 @@ static void put_text_msg(void *user_data, const uint8_t *msg, int len) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", "mod_spandsp"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "tdd"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "TDD MESSAGE"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "TDD-Data", (char *)msg); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(pvt->session)); switch_event_add_body(event, "%s\n\n", (char *)msg); From 4654bda84aee989a59e8bb51fc1c34981653797f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Jul 2012 11:20:05 -0500 Subject: [PATCH 4/5] FS-4374 try this: it will set the stack size for the whole app to 240 if its too big or too small, if there are system limits, fs may have to be run as root and drop privs to be allowed to change this setting --- src/switch.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/switch.c b/src/switch.c index 3903a15604..30a6f1e7e1 100644 --- a/src/switch.c +++ b/src/switch.c @@ -793,12 +793,11 @@ int main(int argc, char *argv[]) memset(&rlp, 0, sizeof(rlp)); getrlimit(RLIMIT_STACK, &rlp); - if (rlp.rlim_max > SWITCH_THREAD_STACKSIZE) { + if (rlp.rlim_cur != SWITCH_THREAD_STACKSIZE) { char buf[1024] = ""; int i = 0; - - fprintf(stderr, "Error: stacksize %d is too large: run ulimit -s %d from your shell before starting the application.\nauto-adjusting stack size for optimal performance...\n", - (int) (rlp.rlim_max / 1024), SWITCH_THREAD_STACKSIZE / 1024); + fprintf(stderr, "Error: stacksize %d is not optimal: run ulimit -s %d from your shell before starting the application.\nauto-adjusting stack size for optimal performance...\n", + (int) (rlp.rlim_cur / 1024), SWITCH_THREAD_STACKSIZE / 1024); memset(&rlp, 0, sizeof(rlp)); rlp.rlim_cur = SWITCH_THREAD_STACKSIZE; From d32a72bcc10af5aadf8ec6611254392f2291067a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 2 Jul 2012 11:49:42 -0500 Subject: [PATCH 5/5] show current process stack size from status command where supported --- .../applications/mod_commands/mod_commands.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 65518dc0d3..dd29136dca 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1721,6 +1721,14 @@ SWITCH_STANDARD_API(lan_addr_function) return SWITCH_STATUS_SUCCESS; } +#include "switch_private.h" +#ifndef WIN32 +#ifdef HAVE_SETRLIMIT +#include +#endif +#endif + + SWITCH_STANDARD_API(status_function) { uint8_t html = 0; @@ -1728,6 +1736,11 @@ SWITCH_STANDARD_API(status_function) char *http = NULL; int sps = 0, last_sps = 0; const char *var; +#ifdef HAVE_SETRLIMIT + struct rlimit rlp; +#endif + + switch_core_measure_time(switch_core_uptime(), &duration); @@ -1764,6 +1777,14 @@ SWITCH_STANDARD_API(status_function) stream->write_function(stream, "%d session(s) max\n", switch_core_session_limit(0)); stream->write_function(stream, "min idle cpu %0.2f/%0.2f\n", switch_core_min_idle_cpu(-1.0), switch_core_idle_cpu()); +#ifdef HAVE_SETRLIMIT + memset(&rlp, 0, sizeof(rlp)); + getrlimit(RLIMIT_STACK, &rlp); + + stream->write_function(stream, "Current Stack Size/Max %ldK/%ldK\n", rlp.rlim_cur / 1024, rlp.rlim_max / 1024); +#endif + + if (html) { stream->write_function(stream, "\n"); }