From b9fa4e123fb02527c351d609dce482ec53234c17 Mon Sep 17 00:00:00 2001 From: Brian West Date: Mon, 23 Sep 2013 14:02:54 -0500 Subject: [PATCH 1/9] Add ability to specifiy the source port on the stun request --- src/mod/applications/mod_commands/mod_commands.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 2b7804dd31..169456c421 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1329,6 +1329,8 @@ SWITCH_STANDARD_API(stun_function) switch_port_t port = 0; switch_memory_pool_t *pool = NULL; char *error = ""; + char *argv[3] = { 0 }; + char *mycmd = NULL; ip = ip_buf; @@ -1337,9 +1339,15 @@ SWITCH_STANDARD_API(stun_function) return SWITCH_STATUS_SUCCESS; } - stun_ip = strdup(cmd); + mycmd = strdup(cmd); + switch_split(mycmd, ' ', argv); + + stun_ip = argv[0]; + switch_assert(stun_ip); + port = argv[1] ? atoi(argv[1]) : 0; + if ((p = strchr(stun_ip, ':'))) { int iport; *p++ = '\0'; @@ -1374,7 +1382,7 @@ SWITCH_STANDARD_API(stun_function) } switch_core_destroy_memory_pool(&pool); - free(stun_ip); + switch_safe_free(mycmd); return SWITCH_STATUS_SUCCESS; } From 99c681f3675f0d5b3241fff46d357c30c7acec42 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 23 Sep 2013 18:31:16 -0500 Subject: [PATCH 2/9] FS-5820 --resolve --- src/switch_ivr_originate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 9825681475..52ef822cad 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -927,7 +927,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec Error!\n"); if (caller_channel) { - switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE); + switch_channel_hangup(caller_channel, SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL); } read_codec = NULL; goto done; @@ -1254,7 +1254,7 @@ static switch_status_t setup_ringback(originate_global_t *oglobals, originate_st switch_core_session_set_read_codec(oglobals->session, write_codec); } else { switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_ERROR, "Codec Error!\n"); - switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE); + switch_channel_hangup(caller_channel, SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL); read_codec = NULL; switch_goto_status(SWITCH_STATUS_BREAK, end); } From d1c58a8e24119d3260cfca41ea2b46fef6cead56 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 23 Sep 2013 21:59:01 -0500 Subject: [PATCH 3/9] move thread launch to be after config check for back-compat mode in event handler --- src/switch_event.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/switch_event.c b/src/switch_event.c index b87d1d4d4b..88863153c6 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -644,31 +644,11 @@ SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool) switch_find_local_ip(guess_ip_v6, sizeof(guess_ip_v6), NULL, AF_INET6); - //switch_queue_create(&EVENT_QUEUE[0], POOL_COUNT_MAX + 10, THRUNTIME_POOL); - //switch_queue_create(&EVENT_QUEUE[1], POOL_COUNT_MAX + 10, THRUNTIME_POOL); - //switch_queue_create(&EVENT_QUEUE[2], POOL_COUNT_MAX + 10, THRUNTIME_POOL); #ifdef SWITCH_EVENT_RECYCLE switch_queue_create(&EVENT_RECYCLE_QUEUE, 250000, THRUNTIME_POOL); switch_queue_create(&EVENT_HEADER_RECYCLE_QUEUE, 250000, THRUNTIME_POOL); #endif - //switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - - if (runtime.events_use_dispatch) { - switch_queue_create(&EVENT_DISPATCH_QUEUE, DISPATCH_QUEUE_LEN * MAX_DISPATCH, pool); - switch_event_launch_dispatch_threads(1); - } - - //switch_thread_create(&EVENT_QUEUE_THREADS[0], thd_attr, switch_event_thread, EVENT_QUEUE[0], RUNTIME_POOL); - //switch_thread_create(&EVENT_QUEUE_THREADS[1], thd_attr, switch_event_thread, EVENT_QUEUE[1], RUNTIME_POOL); - //switch_thread_create(&EVENT_QUEUE_THREADS[2], thd_attr, switch_event_thread, EVENT_QUEUE[2], RUNTIME_POOL); - - if (runtime.events_use_dispatch) { - while (!THREAD_COUNT) { - switch_cond_next(); - } - } - switch_mutex_lock(EVENT_QUEUE_MUTEX); SYSTEM_RUNNING = 1; switch_mutex_unlock(EVENT_QUEUE_MUTEX); @@ -1921,6 +1901,20 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(const char *file, con if (runtime.events_use_dispatch) { + if (!EVENT_DISPATCH_QUEUE) { + switch_mutex_lock(BLOCK); + + if (!EVENT_DISPATCH_QUEUE) { + switch_queue_create(&EVENT_DISPATCH_QUEUE, DISPATCH_QUEUE_LEN * MAX_DISPATCH, THRUNTIME_POOL); + switch_event_launch_dispatch_threads(1); + + while (!THREAD_COUNT) { + switch_cond_next(); + } + } + switch_mutex_unlock(BLOCK); + } + if (switch_event_queue_dispatch_event(event) != SWITCH_STATUS_SUCCESS) { switch_event_destroy(event); return SWITCH_STATUS_FALSE; From e6bfd005023aa874c74ff0e1b203d39ecfc386f7 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 24 Sep 2013 13:25:51 -0400 Subject: [PATCH 4/9] FS-5819: fix incorrect true type in call to switch_core_session_reset --- src/switch_core_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 81571eff1b..feeab60238 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -1394,7 +1394,7 @@ SWITCH_DECLARE(void) switch_core_session_perform_destroy(switch_core_session_t * switch_channel_get_name((*session)->channel), switch_channel_state_name(switch_channel_get_state((*session)->channel))); - switch_core_session_reset(*session, TRUE, SWITCH_TRUE); + switch_core_session_reset(*session, SWITCH_TRUE, SWITCH_TRUE); switch_core_media_bug_remove_all(*session); switch_ivr_deactivate_unicast(*session); From 9155e6b21792fe76501d1367cdcb9465076f90ea Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 24 Sep 2013 13:27:39 -0400 Subject: [PATCH 5/9] FS-5819: fix var type usage outside the range of the enum --- src/switch_apr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/switch_apr.c b/src/switch_apr.c index f13bdcd618..d7717290bd 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -717,7 +717,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_connect(switch_socket_t *sock, swi SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const char *buf, switch_size_t *len) { - switch_status_t status = SWITCH_STATUS_SUCCESS; + int status = SWITCH_STATUS_SUCCESS; switch_size_t req = *len, wrote = 0, need = *len; int to_count = 0; @@ -737,7 +737,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const } *len = wrote; - return status; + return (switch_status_t)status; } SWITCH_DECLARE(switch_status_t) switch_socket_send_nonblock(switch_socket_t *sock, const char *buf, switch_size_t *len) @@ -760,7 +760,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, swit SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t *sock, char *buf, switch_size_t *len) { - switch_status_t r; + int r; r = apr_socket_recv(sock, buf, len); @@ -768,7 +768,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t *sock, char * r = SWITCH_STATUS_BREAK; } - return r; + return (switch_status_t)r; } SWITCH_DECLARE(switch_status_t) switch_sockaddr_create(switch_sockaddr_t **sa, switch_memory_pool_t *pool) @@ -866,7 +866,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_atmark(switch_socket_t *sock, int SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, size_t *len) { - apr_status_t r = SWITCH_STATUS_GENERR; + int r = SWITCH_STATUS_GENERR; if (from && sock && (r = apr_socket_recvfrom(from, sock, flags, buf, len)) == APR_SUCCESS) { from->port = ntohs(from->sa.sin.sin_port); @@ -879,7 +879,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, r = SWITCH_STATUS_BREAK; } - return r; + return (switch_status_t)r; } /* poll stubs */ From 135b1d70bbbe8deb4d9a73f4ca84b2e1972b11e1 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Wed, 25 Sep 2013 20:02:39 +0800 Subject: [PATCH 6/9] only write when it make sense --- src/switch_core_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 2b3c3b6d66..aad6192ece 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -773,7 +773,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi switch_buffer_create_dynamic(&session->raw_read_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, 0); } - if (!switch_buffer_write(session->raw_read_buffer, read_frame->data, read_frame->datalen)) { + if (read_frame->datalen && (!switch_buffer_write(session->raw_read_buffer, read_frame->data, read_frame->datalen))) { status = SWITCH_STATUS_MEMERR; goto done; } From 07d009537f6e311f632f16bd658c4f490a624325 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Thu, 26 Sep 2013 03:44:37 +0800 Subject: [PATCH 7/9] FreeSWITCH will choose the right system defaults for you --- src/switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch.c b/src/switch.c index 8624682bc5..5a16fca2b3 100644 --- a/src/switch.c +++ b/src/switch.c @@ -435,7 +435,7 @@ static const char usage[] = "\t-version -- print the version and exit\n" "\t-rp -- enable high(realtime) priority settings\n" "\t-lp -- enable low priority settings\n" - "\t-np -- enable normal priority settings (system defaults)\n" + "\t-np -- enable normal priority settings\n" "\t-vg -- run under valgrind\n" "\t-nosql -- disable internal sql scoreboard\n" "\t-heavy-timer -- Heavy Timer, possibly more accurate but at a cost\n" From 47221d2e156aa28de35c9471f52bb81d2a71f2f5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 26 Sep 2013 10:21:05 -0500 Subject: [PATCH 8/9] add gl git wrapper script to inline jira summaries into git log --- support-d/gl | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 support-d/gl diff --git a/support-d/gl b/support-d/gl new file mode 100755 index 0000000000..c4e878ba98 --- /dev/null +++ b/support-d/gl @@ -0,0 +1,82 @@ +#!/usr/bin/perl + +my $pager = `which less` || `which more`; +my $tmpdir = "/tmp/FSJIRA"; + +system("mkdir -p $tmpdir"); + +my $cmd = "git log " . join(" ", @ARGV); + +open(CMD, "$cmd |"); +open(PAGER, "|$pager"); +select PAGER; + +while(my $line = ) { + + print $line; + + if ($line =~ /([A-Z]+\-[0-9]+)/) { + my $bug = $1; + my $txt = bugtxt($bug); + if ($txt) { + print "=" x 80 . "\n"; + print $txt; + print "=" x 80 . "\n"; + } + } +} + +close(CMD); +close(PAGER); + +sub catfile($) { + my $file = shift; + open(I, $file) or return; + $/ = undef; + my $txt = ; + $/ = "\n"; + close(I); + return $txt; +} + + +sub bugtxt($) +{ + my $bug = shift or return ""; + my $now = time; + my $tmp; + + $bug =~ s/\.\.//g; + $bug =~ s/^\///g; + $bug =~ s/~//g; + $bug =~ s/[^a-zA-Z0-9\-]//g; + + $tmp = "$tmpdir/$bug.txt"; + + if(-f $tmp) { + return catfile($tmp); + } + + my $cmd = "wget -q http://jira.freeswitch.org/si/jira.issueviews:issue-xml/$bug/$bug.xml -O $tmp"; + + system($cmd); + + my $txt = catfile($tmp); + + my ($a,$title) = $txt =~ /\(.*?)\<\/title\>/smg; + my ($status) = $txt =~ /\(.*?)\<\/status\>/smg; + my ($a,$des) = $txt =~ /\(.*?)\<\/description\>/smg; + my ($alogin, $aname) = $txt =~ /\(.*?)\<\/assignee\>/smg; + my ($rlogin, $rname) = $txt =~ /\(.*?)\<\/reporter\>/smg; + + + if ($rname && $aname) { + my $data = "$title\nReporter: $rname [$rlogin]\nAssignee: $aname [$alogin]\nStatus: $status\nhttp://jira.freeswitch.org/browse/$bug\n"; + open(O, ">$tmp"); + print O $data; + close(O); + return $data; + } else { + unlink($tmp); + } +} From 6078451baeccfad2a44046ee6bb6386175d2ba01 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 26 Sep 2013 13:31:35 -0400 Subject: [PATCH 9/9] FS-5819: add missing status values that we check from apr to the enum so the compiler knows the right type to use for the enum --- src/include/switch_types.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index fd5208eea6..27a88dcc73 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1041,7 +1041,9 @@ typedef enum { SWITCH_STATUS_FOUND, SWITCH_STATUS_CONTINUE, SWITCH_STATUS_TERM, - SWITCH_STATUS_NOT_INITALIZED + SWITCH_STATUS_NOT_INITALIZED, + SWITCH_STATUS_XBREAK = 35, + SWITCH_STATUS_WINBREAK = 730035 } switch_status_t;