[Freeswitch-svn] [commit] r10410 - in freeswitch/trunk/src: . include mod/applications/mod_conference mod/applications/mod_fsv mod/applications/mod_skel mod/asr_tts/mod_cepstral mod/endpoints/mod_dingaling mod/endpoints/mod_iax mod/endpoints/mod_loopback mod/endpoints/mod_portaudio mod/endpoints/mod_reference mod/endpoints/mod_sofia mod/endpoints/mod_unicall mod/endpoints/mod_woomera mod/event_handlers/mod_event_multicast mod/event_handlers/mod_event_socket mod/event_handlers/mod_zeroconf mod/formats/mod_shout mod/languages/mod_spidermonkey
FreeSWITCH SVN
anthm at freeswitch.org
Fri Nov 14 15:31:21 PST 2008
Author: anthm
Date: Fri Nov 14 18:31:21 2008
New Revision: 10410
Log:
more stuff
Modified:
freeswitch/trunk/src/include/switch_core.h
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c
freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c
freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c
freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c
freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c
freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
freeswitch/trunk/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/switch_apr.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_console.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_core_memory.c
freeswitch/trunk/src/switch_core_sqldb.c
freeswitch/trunk/src/switch_core_state_machine.c
freeswitch/trunk/src/switch_event.c
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_ivr_async.c
freeswitch/trunk/src/switch_ivr_bridge.c
freeswitch/trunk/src/switch_ivr_originate.c
freeswitch/trunk/src/switch_log.c
freeswitch/trunk/src/switch_rtp.c
freeswitch/trunk/src/switch_stun.c
freeswitch/trunk/src/switch_time.c
Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h (original)
+++ freeswitch/trunk/src/include/switch_core.h Fri Nov 14 18:31:21 2008
@@ -1682,8 +1682,8 @@
SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string);
SWITCH_DECLARE(switch_status_t) switch_console_set_alias(const char *string);
SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
-SWITCH_DECLARE(void) switch_cond_yield(uint32_t ms);
-
+SWITCH_DECLARE(void) switch_cond_yield(switch_interval_time_t t);
+SWITCH_DECLARE(void) switch_cond_next();
///\}
/*!
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Fri Nov 14 18:31:21 2008
@@ -1195,7 +1195,7 @@
if (conference->video_running == 1) {
conference->video_running = -1;
while (conference->video_running) {
- switch_yield(1000);
+ switch_cond_next();
}
}
@@ -2010,7 +2010,7 @@
if (use_timer) {
switch_core_timer_next(&timer);
} else {
- switch_yield(1000);
+ switch_cond_next();
}
} /* Rinse ... Repeat */
@@ -2032,7 +2032,7 @@
/* Wait for the input thread to end */
while (switch_test_flag(member, MFLAG_ITHREAD)) {
- switch_yield(1000);
+ switch_cond_next();
}
}
Modified: freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c Fri Nov 14 18:31:21 2008
@@ -203,7 +203,7 @@
if (eh.up) {
while (eh.up) {
- switch_yield(1000);
+ switch_cond_next();
}
}
@@ -320,7 +320,7 @@
switch_core_session_write_video_frame(session, &vid_frame, SWITCH_IO_FLAG_NONE, 0);
}
if (ts && last && last != ts) {
- switch_yield(1000);
+ switch_cond_next();
}
last = ts;
} else {
Modified: freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c Fri Nov 14 18:31:21 2008
@@ -64,7 +64,7 @@
{
while(looping)
{
- switch_yield(1000);
+ switch_cond_next();
}
return SWITCH_STATUS_TERM;
}
Modified: freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c (original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c Fri Nov 14 18:31:21 2008
@@ -302,7 +302,7 @@
status = SWITCH_STATUS_SUCCESS;
break;
}
- switch_yield(1000);
+ switch_cond_next();
continue;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Fri Nov 14 18:31:21 2008
@@ -1112,7 +1112,7 @@
if (switch_test_flag(tech_pvt, TFLAG_BYE) || !switch_test_flag(tech_pvt, TFLAG_IO)) {
goto done;
}
- switch_yield(1000);
+ switch_cond_next();
}
if (switch_channel_get_state(channel) >= CS_HANGUP || switch_test_flag(tech_pvt, TFLAG_BYE)) {
Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c Fri Nov 14 18:31:21 2008
@@ -583,7 +583,7 @@
while (switch_test_flag(tech_pvt, TFLAG_IO)) {
if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
- switch_yield(1000);
+ switch_cond_next();
continue;
}
if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
@@ -615,7 +615,7 @@
return SWITCH_STATUS_SUCCESS;
}
- switch_yield(1000);
+ switch_cond_next();
if (++ms_count >= 30000) {
break;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c Fri Nov 14 18:31:21 2008
@@ -491,7 +491,7 @@
break;
}
- switch_yield(1000);
+ switch_cond_next();
}
if (switch_test_flag(tech_pvt, TFLAG_LINKED)) {
Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c Fri Nov 14 18:31:21 2008
@@ -131,7 +131,7 @@
PaUtil_FlushRingBuffer(&aStream->outFIFO);
return 0;
}
- switch_yield(1000);
+ switch_cond_next();
}
}
return numFrames;
@@ -169,7 +169,7 @@
if (bytesRead) {
p += bytesRead;
} else {
- switch_yield(1000);
+ switch_cond_next();
}
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c Fri Nov 14 18:31:21 2008
@@ -309,7 +309,7 @@
return SWITCH_STATUS_SUCCESS;
}
- switch_yield(1000);
+ switch_cond_next();
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Fri Nov 14 18:31:21 2008
@@ -453,7 +453,7 @@
// Maybe we should timeout?
while(switch_channel_ready(channel) && !switch_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
- switch_yield(1000);
+ switch_cond_next();
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n");
}
@@ -2549,7 +2549,7 @@
switch_event_unbind_callback(general_event_handler);
while (mod_sofia_globals.threads) {
- switch_yield(1000);
+ switch_cond_next();
if (++sanity >= 10000) {
break;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Fri Nov 14 18:31:21 2008
@@ -3159,7 +3159,7 @@
break;
} else if (result == SWITCH_CORE_DB_BUSY) {
running++;
- switch_yield(1000);
+ switch_cond_next();
continue;
}
break;
Modified: freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c Fri Nov 14 18:31:21 2008
@@ -1052,7 +1052,7 @@
return SWITCH_STATUS_SUCCESS;
}
- switch_yield(1000);
+ switch_cond_next();
}
return SWITCH_STATUS_FALSE;
Modified: freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c Fri Nov 14 18:31:21 2008
@@ -338,7 +338,7 @@
if (switch_test_flag(tech_pvt, TFLAG_MEDIA)) {
break;
}
- switch_yield(1000);
+ switch_cond_next();
}
if (!tech_pvt->udp_socket) {
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c Fri Nov 14 18:31:21 2008
@@ -253,7 +253,7 @@
globals.running = -1;
while (x < 100000 && globals.running) {
x++;
- switch_yield(1000);
+ switch_cond_next();
}
}
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Fri Nov 14 18:31:21 2008
@@ -1049,7 +1049,7 @@
}
}
if (do_sleep) {
- switch_yield(1000);
+ switch_cond_next();
}
}
Modified: freeswitch/trunk/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c Fri Nov 14 18:31:21 2008
@@ -303,7 +303,7 @@
sw_uint32 ms;
ms = 100;
sw_discovery_step(globals.discovery, &ms);
- switch_yield(1000);
+ switch_cond_next();
}
RUNNING = 0;
return SWITCH_STATUS_TERM;
Modified: freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c Fri Nov 14 18:31:21 2008
@@ -1195,7 +1195,7 @@
switch_buffer_unlock(buffer);
} else {
if (!bytes) {
- switch_yield(1000);
+ switch_cond_next();
continue;
}
memset(buf, 0, bytes);
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Fri Nov 14 18:31:21 2008
@@ -2135,7 +2135,7 @@
break;
}
- switch_yield(1000);
+ switch_cond_next();
}
JS_ResumeRequest(cx, saveDepth);
check_hangup_hook(jss, &ret);
@@ -2179,7 +2179,7 @@
break;
}
- switch_yield(1000);
+ switch_cond_next();
}
JS_ResumeRequest(cx, saveDepth);
check_hangup_hook(jss, &ret);
Modified: freeswitch/trunk/src/switch_apr.c
==============================================================================
--- freeswitch/trunk/src/switch_apr.c (original)
+++ freeswitch/trunk/src/switch_apr.c Fri Nov 14 18:31:21 2008
@@ -683,7 +683,7 @@
status = SWITCH_STATUS_FALSE;
break;
}
- switch_yield(1000);
+ switch_cond_next();
} else {
to_count = 0;
}
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Fri Nov 14 18:31:21 2008
@@ -683,7 +683,7 @@
if (mystate != ostate || state >= CS_HANGUP || state == want_state) {
break;
}
- switch_yield(1000);
+ switch_cond_next();
}
}
@@ -709,7 +709,7 @@
}
}
- switch_yield(1000);
+ switch_cond_next();
if (super_channel && !switch_channel_ready(super_channel)) {
return SWITCH_STATUS_FALSE;
Modified: freeswitch/trunk/src/switch_console.c
==============================================================================
--- freeswitch/trunk/src/switch_console.c (original)
+++ freeswitch/trunk/src/switch_console.c Fri Nov 14 18:31:21 2008
@@ -449,7 +449,7 @@
free(cmd);
}
}
- switch_yield(1000);
+ switch_cond_next();
}
switch_core_destroy_memory_pool(&pool);
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Fri Nov 14 18:31:21 2008
@@ -360,6 +360,7 @@
}
ts->objs[0] = obj;
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_threadattr_priority_increase(thd_attr);
switch_thread_create(&thread, thd_attr, func, ts, pool);
}
}
Modified: freeswitch/trunk/src/switch_core_memory.c
==============================================================================
--- freeswitch/trunk/src/switch_core_memory.c (original)
+++ freeswitch/trunk/src/switch_core_memory.c Fri Nov 14 18:31:21 2008
@@ -444,7 +444,7 @@
#ifndef INSTANTLY_DESTROY_POOLS
memory_manager.pool_thread_running = -1;
while (memory_manager.pool_thread_running) {
- switch_yield(1000);
+ switch_cond_next();
}
#endif
}
@@ -503,7 +503,7 @@
switch_thread_create(&thread, thd_attr, pool_thread, NULL, memory_manager.memory_pool);
while (!memory_manager.pool_thread_running) {
- switch_yield(1000);
+ switch_cond_next();
}
#endif
Modified: freeswitch/trunk/src/switch_core_sqldb.c
==============================================================================
--- freeswitch/trunk/src/switch_core_sqldb.c (original)
+++ freeswitch/trunk/src/switch_core_sqldb.c Fri Nov 14 18:31:21 2008
@@ -220,7 +220,7 @@
}
if (nothing_in_queue) {
- switch_yield(1000);
+ switch_cond_next();
}
}
Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c (original)
+++ freeswitch/trunk/src/switch_core_state_machine.c Fri Nov 14 18:31:21 2008
@@ -462,7 +462,7 @@
if (endstate == switch_channel_get_running_state(session->channel)) {
if (endstate == CS_NEW) {
- switch_yield(1000);
+ switch_cond_next();
} else {
switch_thread_cond_wait(session->cond, session->mutex);
}
Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c (original)
+++ freeswitch/trunk/src/switch_event.c Fri Nov 14 18:31:21 2008
@@ -446,7 +446,7 @@
}
while (x < 10000 && THREAD_COUNT) {
- switch_yield(1000);
+ switch_cond_next();
if (THREAD_COUNT == last) {
x++;
}
@@ -537,7 +537,7 @@
switch_thread_create(&thread, thd_attr, switch_event_thread, EVENT_QUEUE[2], RUNTIME_POOL);
while (!THREAD_COUNT) {
- switch_yield(1000);
+ switch_cond_next();
}
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Fri Nov 14 18:31:21 2008
@@ -112,13 +112,13 @@
}
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
- switch_yield(1000);
+ switch_cond_next();
continue;
}
if (switch_channel_test_flag(channel, CF_SERVICE) ||
(!switch_channel_test_flag(channel, CF_ANSWERED) && !switch_channel_test_flag(channel, CF_EARLY_MEDIA))) {
- switch_yield(1000);
+ switch_cond_next();
} else {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) {
@@ -709,7 +709,7 @@
}
if (switch_channel_test_flag(channel, CF_SERVICE)) {
- switch_yield(1000);
+ switch_cond_next();
} else {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
}
@@ -824,7 +824,7 @@
}
if (switch_channel_test_flag(channel, CF_SERVICE)) {
- switch_yield(1000);
+ switch_cond_next();
} else {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) {
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Fri Nov 14 18:31:21 2008
@@ -157,7 +157,7 @@
#ifdef SWITCH_VIDEO_IN_THREADS
if (eh.up) {
while (eh.up) {
- switch_yield(1000);
+ switch_cond_next();
}
}
#endif
Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c (original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c Fri Nov 14 18:31:21 2008
@@ -913,7 +913,7 @@
}
while (switch_channel_get_state(peer_channel) == CS_EXCHANGE_MEDIA) {
- switch_yield(1000);
+ switch_cond_next();
}
switch_core_session_rwunlock(peer_session);
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Fri Nov 14 18:31:21 2008
@@ -497,7 +497,7 @@
}
}
} else {
- switch_yield(1000);
+ switch_cond_next();
}
}
@@ -1199,7 +1199,7 @@
goto notready;
}
- switch_yield(10000);
+ switch_yield(100000);
}
check_per_channel_timeouts(peer_channels, per_channel_timelimit_sec, per_channel_progress_timelimit_sec, and_argc, start);
@@ -1432,7 +1432,7 @@
}
} else {
- switch_yield(10000);
+ switch_yield(100000);
}
}
Modified: freeswitch/trunk/src/switch_log.c
==============================================================================
--- freeswitch/trunk/src/switch_log.c (original)
+++ freeswitch/trunk/src/switch_log.c Fri Nov 14 18:31:21 2008
@@ -402,7 +402,7 @@
switch_thread_create(&thread, thd_attr, log_thread, NULL, LOG_POOL);
while (!THREAD_RUNNING) {
- switch_yield(1000);
+ switch_cond_next();
}
if (colorize) {
@@ -438,7 +438,7 @@
THREAD_RUNNING = -1;
switch_queue_push(LOG_QUEUE, NULL);
while (THREAD_RUNNING) {
- switch_yield(1000);
+ switch_cond_next();
}
switch_core_memory_reclaim_logger();
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Fri Nov 14 18:31:21 2008
@@ -558,7 +558,7 @@
if (++x > 1000) {
break;
}
- switch_yield(1000);
+ switch_cond_next();
}
switch_socket_opt_set(new_sock, SWITCH_SO_NONBLOCK, FALSE);
@@ -1537,7 +1537,7 @@
rtp_session->recv_msg.header.ts = htonl(jb_frame->ts);
} else if (!bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { /* We're late! We're Late! */
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) {
- switch_yield(1000);
+ switch_cond_next();
continue;
}
Modified: freeswitch/trunk/src/switch_stun.c
==============================================================================
--- freeswitch/trunk/src/switch_stun.c (original)
+++ freeswitch/trunk/src/switch_stun.c Fri Nov 14 18:31:21 2008
@@ -518,7 +518,7 @@
switch_socket_close(sock);
return SWITCH_STATUS_TIMEOUT;
}
- switch_yield(1000);
+ switch_cond_next();
}
switch_socket_close(sock);
Modified: freeswitch/trunk/src/switch_time.c
==============================================================================
--- freeswitch/trunk/src/switch_time.c (original)
+++ freeswitch/trunk/src/switch_time.c Fri Nov 14 18:31:21 2008
@@ -172,14 +172,14 @@
SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t)
{
- if (t < 1000) {
+ if (t < 1000 || t >= 10000) {
do_sleep(t);
return;
}
#ifndef DISABLE_1MS_COND
if (globals.use_cond_yield == 1) {
- switch_cond_yield((uint32_t)(t / 1000));
+ switch_cond_yield(t);
return;
}
#endif
@@ -188,20 +188,39 @@
}
-SWITCH_DECLARE(void) switch_cond_yield(uint32_t ms)
+SWITCH_DECLARE(void) switch_cond_next(void)
{
- if (!ms) return;
-
- if (globals.use_cond_yield != 1) {
- do_sleep(ms * 1000);
+#ifdef DISABLE_1MS_COND
+ do_sleep(1000);
+#else
+ if (!runtime.timestamp || globals.use_cond_yield != 1) {
+ do_sleep(1000);
return;
}
-
switch_mutex_lock(TIMER_MATRIX[1].mutex);
- while(globals.RUNNING == 1 && globals.use_cond_yield == 1 && ms--) {
- switch_thread_cond_wait(TIMER_MATRIX[1].cond, TIMER_MATRIX[1].mutex);
- }
+ switch_thread_cond_wait(TIMER_MATRIX[1].cond, TIMER_MATRIX[1].mutex);
switch_mutex_unlock(TIMER_MATRIX[1].mutex);
+#endif
+}
+
+SWITCH_DECLARE(void) switch_cond_yield(switch_interval_time_t t)
+{
+ switch_time_t want;
+ if (!t) return;
+
+ if (!runtime.timestamp || globals.use_cond_yield != 1) {
+ do_sleep(t);
+ return;
+ }
+ want = runtime.timestamp + t;
+ while(globals.RUNNING == 1 && globals.use_cond_yield == 1 && runtime.timestamp < want) {
+ switch_mutex_lock(TIMER_MATRIX[1].mutex);
+ if (runtime.timestamp < want) {
+ switch_thread_cond_wait(TIMER_MATRIX[1].cond, TIMER_MATRIX[1].mutex);
+ }
+ switch_mutex_unlock(TIMER_MATRIX[1].mutex);
+ }
+
}
@@ -292,22 +311,28 @@
static switch_status_t timer_next(switch_timer_t *timer)
{
timer_private_t *private_info = timer->private_info;
- timer_step(timer);
-#if 1
- switch_mutex_lock(TIMER_MATRIX[timer->interval].mutex);
- while (globals.RUNNING == 1 && private_info->ready && TIMER_MATRIX[timer->interval].tick < private_info->reference) {
- check_roll();
- switch_thread_cond_wait(TIMER_MATRIX[timer->interval].cond, TIMER_MATRIX[timer->interval].mutex);
- }
- switch_mutex_unlock(TIMER_MATRIX[timer->interval].mutex);
+#ifdef DISABLE_1MS_COND
+ int cond_index = timer->interval;
#else
+ int cond_index = 1;
+#endif
+
+ timer_step(timer);
+
while (globals.RUNNING == 1 && private_info->ready && TIMER_MATRIX[timer->interval].tick < private_info->reference) {
check_roll();
- do_sleep(1000);
+ if (globals.use_cond_yield == 1) {
+ switch_mutex_lock(TIMER_MATRIX[cond_index].mutex);
+ if (TIMER_MATRIX[timer->interval].tick < private_info->reference) {
+ switch_thread_cond_wait(TIMER_MATRIX[cond_index].cond, TIMER_MATRIX[cond_index].mutex);
+ }
+ switch_mutex_unlock(TIMER_MATRIX[cond_index].mutex);
+ } else {
+ do_sleep(1000);
+ }
}
-#endif
-
+
if (globals.RUNNING == 1) {
return SWITCH_STATUS_SUCCESS;
}
@@ -486,7 +511,7 @@
if ((current_ms % x) == 0) {
if (TIMER_MATRIX[x].count) {
TIMER_MATRIX[x].tick++;
-#if 1
+#ifdef DISABLE_1MS_COND
if (TIMER_MATRIX[x].mutex && switch_mutex_trylock(TIMER_MATRIX[x].mutex) == SWITCH_STATUS_SUCCESS) {
switch_thread_cond_broadcast(TIMER_MATRIX[x].cond);
switch_mutex_unlock(TIMER_MATRIX[x].mutex);
@@ -726,11 +751,13 @@
timer_interface->timer_destroy = timer_destroy;
/* indicate that the module should continue to be loaded */
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_NOUNLOAD;
}
SWITCH_MODULE_SHUTDOWN_FUNCTION(softtimer_shutdown)
{
+ globals.use_cond_yield = 0;
+
if (globals.RUNNING == 1) {
switch_mutex_lock(globals.mutex);
globals.RUNNING = -1;
More information about the Freeswitch-svn
mailing list