mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-12 21:24:14 +00:00
fix unload
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9471 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
94ddd96b8b
commit
6f4f1d1db3
@ -34,8 +34,9 @@
|
|||||||
#define DEFAULT_PREBUFFER_SIZE 1024 * 16
|
#define DEFAULT_PREBUFFER_SIZE 1024 * 16
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load);
|
SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load);
|
||||||
SWITCH_MODULE_DEFINITION(mod_local_stream, mod_local_stream_load, NULL, NULL);
|
|
||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_local_stream_shutdown);
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_local_stream_shutdown);
|
||||||
|
SWITCH_MODULE_DEFINITION(mod_local_stream, mod_local_stream_load, mod_local_stream_shutdown, NULL);
|
||||||
|
|
||||||
|
|
||||||
struct local_stream_source;
|
struct local_stream_source;
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ static struct {
|
|||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
static int RUNNING = 1;
|
static int RUNNING = 1;
|
||||||
|
static int THREADS = 0;
|
||||||
|
|
||||||
struct local_stream_context {
|
struct local_stream_context {
|
||||||
struct local_stream_source *source;
|
struct local_stream_source *source;
|
||||||
@ -107,6 +109,10 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
|||||||
switch_size_t used;
|
switch_size_t used;
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
|
|
||||||
|
switch_mutex_lock(globals.mutex);
|
||||||
|
THREADS++;
|
||||||
|
switch_mutex_unlock(globals.mutex);
|
||||||
|
|
||||||
if (!source->prebuf) {
|
if (!source->prebuf) {
|
||||||
source->prebuf = DEFAULT_PREBUFFER_SIZE;
|
source->prebuf = DEFAULT_PREBUFFER_SIZE;
|
||||||
}
|
}
|
||||||
@ -257,6 +263,10 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
|||||||
|
|
||||||
switch_core_destroy_memory_pool(&source->pool);
|
switch_core_destroy_memory_pool(&source->pool);
|
||||||
|
|
||||||
|
switch_mutex_lock(globals.mutex);
|
||||||
|
THREADS--;
|
||||||
|
switch_mutex_unlock(globals.mutex);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,7 +517,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load)
|
|||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_local_stream_shutdown)
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_local_stream_shutdown)
|
||||||
{
|
{
|
||||||
RUNNING = 0;
|
RUNNING = 0;
|
||||||
switch_yield(500000);
|
switch_event_unbind_callback(event_handler);
|
||||||
|
|
||||||
|
while(THREADS > 0) {
|
||||||
|
switch_yield(100000);
|
||||||
|
}
|
||||||
|
|
||||||
switch_core_hash_destroy(&globals.source_hash);
|
switch_core_hash_destroy(&globals.source_hash);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user