look in switch.c<br><br>we do it when you say "fsctl shutdown restart" and it works fine over and over.<br><br><br><br><div class="gmail_quote">On Wed, Jul 1, 2009 at 5:52 PM, Tamas <span dir="ltr"><<a href="mailto:jalsot@gmail.com">jalsot@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello,<br>
<br>
I'm trying to embed FS in a C application where I should have to restart<br>
the whole stuff (core) in one process/thread, however it crashes. I<br>
assume, something is not freed up before the new startup. I've used<br>
mrene's fshost example to reproduce the issue:<br>
<br>
Index: contrib/mrene/fshost/main.c<br>
===================================================================<br>
--- contrib/mrene/fshost/main.c (revision 14092)<br>
+++ contrib/mrene/fshost/main.c (working copy)<br>
-82,7 +82,34 @@<br>
<br>
ret = system(buf);<br>
}<br>
+<br>
+<br>
+ /* Here I start my 2nd start */<br>
+<br>
+ /* Initialize libs & globals */<br>
+ printf("Initializing globals...\n");<br>
+ switch_core_setrlimits();<br>
+ switch_core_set_globals();<br>
<br>
+ /* If you need to override configuration directories, you need to<br>
change them in the SWITCH_GLOBAL_dirs global structure */<br>
+ printf("Initializing core...\n");<br>
+ /* Initialize the core and load modules, that will startup FS<br>
completely */<br>
+ if (switch_core_init_and_modload(flags, console, &err) !=<br>
SWITCH_STATUS_SUCCESS) {<br>
+ fprintf(stderr, "Failed to initialize FreeSWITCH's core: %s\n",<br>
err);<br>
+ return 1;<br>
+ }<br>
+<br>
+ printf("Everything OK, Entering runtime loop.\n");<br>
+<br>
+ fflush(stdout);<br>
+<br>
+ /* Go into the runtime loop. If the argument is true, this<br>
basically sets runtime.running = 1 and loops while that is set<br>
+ * If its false, it initializes the libedit for the console, then<br>
does the same thing<br>
+ */<br>
+ switch_core_runtime_loop(!console);<br>
+<br>
+ /* When the runtime loop exits, its time to shutdown */<br>
+ destroy_status = switch_core_destroy();<br>
return ret;<br>
}<br>
<br>
-95,4 +122,4 @@<br>
* End:<br>
* For VIM:<br>
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:<br>
- */<br>
\ No newline at end of file<br>
+ */<br>
<br>
<br>
Here are some gdb backtraces:<br>
<br>
(gdb) bt<br>
#0 0x00007fb418c94a7f in apr_queue_trypush (queue=0x7fb4168e45a8,<br>
data=0x12b4b60) at misc/apr_queue.c:215<br>
#1 0x00007fb418c0464a in switch_queue_trypush (queue=0x7fb4168e45a8,<br>
data=0x12b4b60) at src/switch_apr.c:931<br>
#2 0x00007fb418c3bab8 in switch_event_thread (thread=0x1663a98,<br>
obj=0x12b8398) at src/switch_event.c:305<br>
#3 0x00007fb418ca8c01 in dummy_worker (opaque=0x1663a98) at<br>
threadproc/unix/thread.c:138<br>
#4 0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0<br>
#5 0x00007fb418933fcd in clone () from /lib/libc.so.6<br>
#6 0x0000000000000000 in ?? ()<br>
(gdb) bt full<br>
#0 0x00007fb418c94a7f in apr_queue_trypush (queue=0x7fb4168e45a8,<br>
data=0x12b4b60) at misc/apr_queue.c:215<br>
rv = 0<br>
#1 0x00007fb418c0464a in switch_queue_trypush (queue=0x7fb4168e45a8,<br>
data=0x12b4b60) at src/switch_apr.c:931<br>
s = 0<br>
#2 0x00007fb418c3bab8 in switch_event_thread (thread=0x1663a98,<br>
obj=0x12b8398) at src/switch_event.c:305<br>
pop = 0x12b4b60<br>
event = 0x12b4b60<br>
queue = 0x12b8398<br>
index = 0<br>
my_id = 0<br>
__func__ = "switch_event_thread"<br>
#3 0x00007fb418ca8c01 in dummy_worker (opaque=0x1663a98) at<br>
threadproc/unix/thread.c:138<br>
thread = 0x1663a98<br>
#4 0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0<br>
No symbol table info available.<br>
#5 0x00007fb418933fcd in clone () from /lib/libc.so.6<br>
No symbol table info available.<br>
#6 0x0000000000000000 in ?? ()<br>
No symbol table info available.<br>
<br>
<br>
(gdb) thread apply all bt<br>
<br>
Thread 5 (Thread 31286):<br>
#0 0x00007fb41892c742 in select () from /lib/libc.so.6<br>
#1 0x00007fb418caab2a in apr_sleep (t=100000) at time/unix/time.c:246<br>
#2 0x00007fb418c7aba5 in do_sleep (t=100000) at src/switch_time.c:109<br>
#3 0x00007fb418c7ad95 in switch_sleep (t=100000) at src/switch_time.c:178<br>
#4 0x00007fb418c16b75 in pool_thread (thread=0x1417ff8, obj=0x0) at<br>
src/switch_core_memory.c:531<br>
#5 0x00007fb418ca8c01 in dummy_worker (opaque=0x1417ff8) at<br>
threadproc/unix/thread.c:138<br>
#6 0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0<br>
#7 0x00007fb418933fcd in clone () from /lib/libc.so.6<br>
#8 0x0000000000000000 in ?? ()<br>
<br>
Thread 4 (Thread 31264):<br>
#0 0x00007fb417ffbbc5 in __lll_unlock_wake () from /lib/libpthread.so.0<br>
#1 0x00007fb417ff85c9 in _L_unlock_56 () from /lib/libpthread.so.0<br>
#2 0x00007fb417ff8206 in __pthread_mutex_unlock_usercnt () from<br>
/lib/libpthread.so.0<br>
#3 0x00007fb418ca12de in apr_thread_mutex_unlock (mutex=0x12b83d8) at<br>
locks/unix/thread_mutex.c:121<br>
#4 0x00007fb418c94b78 in apr_queue_trypush (queue=0x12b8398,<br>
data=0x12b4b60) at misc/apr_queue.c:242<br>
#5 0x00007fb418c0464a in switch_queue_trypush (queue=0x12b8398,<br>
data=0x12b4b60) at src/switch_apr.c:931<br>
#6 0x00007fb418c3dfe8 in switch_event_fire_detailed<br>
(file=0x7fb418d55ce0 "src/switch_xml.c", func=0x7fb418d562f0<br>
"switch_xml_open_root", line=1918, event=0x7fff211d0a58, user_data=0x0)<br>
at src/switch_event.c:1128<br>
#7 0x00007fb418c76a66 in switch_xml_open_root (reload=0 '\0',<br>
err=0x7fff211d1110) at src/switch_xml.c:1918<br>
#8 0x00007fb418c76b5e in switch_xml_init (pool=0x126aff8,<br>
err=0x7fff211d1110) at src/switch_xml.c:1945<br>
#9 0x00007fb418c2d78f in switch_core_init (flags=1,<br>
console=SWITCH_TRUE, err=0x7fff211d1110) at src/switch_core.c:1231<br>
#10 0x00007fb418c2e02b in switch_core_init_and_modload (flags=1,<br>
console=SWITCH_TRUE, err=0x7fff211d1110) at src/switch_core.c:1422<br>
#11 0x0000000000400ed7 in main (argc=1, argv=0x7fff211d1628) at main.c:97<br>
<br>
Thread 3 (Thread 31288):<br>
#0 0x00007fb417ff92e9 in pthread_cond_wait@@GLIBC_2.3.2 () from<br>
/lib/libpthread.so.0<br>
#1 0x00007fb418ca13ef in apr_thread_cond_wait (cond=0x14dbb08,<br>
mutex=0x14dbab8) at locks/unix/thread_cond.c:68<br>
#2 0x00007fb418c94c1f in apr_queue_pop (queue=0x14dba78,<br>
data=0x7fb41676c0b8) at misc/apr_queue.c:276<br>
#3 0x00007fb418c045ca in switch_queue_pop (queue=0x14dba78,<br>
data=0x7fb41676c0b8) at src/switch_apr.c:902<br>
#4 0x00007fb418c3ba5e in switch_event_thread (thread=0x1663ac8,<br>
obj=0x14dba78) at src/switch_event.c:289<br>
#5 0x00007fb418ca8c01 in dummy_worker (opaque=0x1663ac8) at<br>
threadproc/unix/thread.c:138<br>
#6 0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0<br>
#7 0x00007fb418933fcd in clone () from /lib/libc.so.6<br>
#8 0x0000000000000000 in ?? ()<br>
<br>
Thread 2 (Thread 31289):<br>
#0 0x00007fb417ff92e9 in pthread_cond_wait@@GLIBC_2.3.2 () from<br>
/lib/libpthread.so.0<br>
#1 0x00007fb418ca13ef in apr_thread_cond_wait (cond=0x159fb18,<br>
mutex=0x159fac8) at locks/unix/thread_cond.c:68<br>
#2 0x00007fb418c94c1f in apr_queue_pop (queue=0x159fa88,<br>
data=0x7fb4167a80b8) at misc/apr_queue.c:276<br>
#3 0x00007fb418c045ca in switch_queue_pop (queue=0x159fa88,<br>
data=0x7fb4167a80b8) at src/switch_apr.c:902<br>
#4 0x00007fb418c3ba5e in switch_event_thread (thread=0x1663af8,<br>
obj=0x159fa88) at src/switch_event.c:289<br>
#5 0x00007fb418ca8c01 in dummy_worker (opaque=0x1663af8) at<br>
threadproc/unix/thread.c:138<br>
#6 0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0<br>
#7 0x00007fb418933fcd in clone () from /lib/libc.so.6<br>
#8 0x0000000000000000 in ?? ()<br>
<br>
Thread 1 (Thread 31287):<br>
#0 0x00007fb418c94a7f in apr_queue_trypush (queue=0x7fb4168e45a8,<br>
data=0x12b4b60) at misc/apr_queue.c:215<br>
#1 0x00007fb418c0464a in switch_queue_trypush (queue=0x7fb4168e45a8,<br>
data=0x12b4b60) at src/switch_apr.c:931<br>
#2 0x00007fb418c3bab8 in switch_event_thread (thread=0x1663a98,<br>
obj=0x12b8398) at src/switch_event.c:305<br>
#3 0x00007fb418ca8c01 in dummy_worker (opaque=0x1663a98) at<br>
threadproc/unix/thread.c:138<br>
#4 0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0<br>
#5 0x00007fb418933fcd in clone () from /lib/libc.so.6<br>
#6 0x0000000000000000 in ?? ()<br>
<br>
(gdb) thread apply all bt full<br>
<br>
Thread 5 (Thread 31286):<br>
#0 0x00007fb41892c742 in select () from /lib/libc.so.6<br>
No symbol table info available.<br>
#1 0x00007fb418caab2a in apr_sleep (t=100000) at time/unix/time.c:246<br>
tv = {tv_sec = 0, tv_usec = 88462}<br>
#2 0x00007fb418c7aba5 in do_sleep (t=100000) at src/switch_time.c:109<br>
No locals.<br>
#3 0x00007fb418c7ad95 in switch_sleep (t=100000) at src/switch_time.c:178<br>
No locals.<br>
#4 0x00007fb418c16b75 in pool_thread (thread=0x1417ff8, obj=0x0) at<br>
src/switch_core_memory.c:531<br>
len = 0<br>
#5 0x00007fb418ca8c01 in dummy_worker (opaque=0x1417ff8) at<br>
threadproc/unix/thread.c:138<br>
thread = 0x1417ff8<br>
#6 0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0<br>
No symbol table info available.<br>
#7 0x00007fb418933fcd in clone () from /lib/libc.so.6<br>
No symbol table info available.<br>
#8 0x0000000000000000 in ?? ()<br>
No symbol table info available.<br>
<br>
Thread 4 (Thread 31264):<br>
#0 0x00007fb417ffbbc5 in __lll_unlock_wake () from /lib/libpthread.so.0<br>
No symbol table info available.<br>
#1 0x00007fb417ff85c9 in _L_unlock_56 () from /lib/libpthread.so.0<br>
No symbol table info available.<br>
#2 0x00007fb417ff8206 in __pthread_mutex_unlock_usercnt () from<br>
/lib/libpthread.so.0<br>
No symbol table info available.<br>
#3 0x00007fb418ca12de in apr_thread_mutex_unlock (mutex=0x12b83d8) at<br>
locks/unix/thread_mutex.c:121<br>
status = 0<br>
#4 0x00007fb418c94b78 in apr_queue_trypush (queue=0x12b8398,<br>
data=0x12b4b60) at misc/apr_queue.c:242<br>
rv = 0<br>
#5 0x00007fb418c0464a in switch_queue_trypush (queue=0x12b8398,<br>
data=0x12b4b60) at src/switch_apr.c:931<br>
s = 0<br>
#6 0x00007fb418c3dfe8 in switch_event_fire_detailed<br>
(file=0x7fb418d55ce0 "src/switch_xml.c", func=0x7fb418d562f0<br>
"switch_xml_open_root", line=1918, event=0x7fff211d0a58, user_data=0x0)<br>
at src/switch_event.c:1128<br>
was = 0<br>
index = 0<br>
__PRETTY_FUNCTION__ = "switch_event_fire_detailed"<br>
__func__ = "switch_event_fire_detailed"<br>
#7 0x00007fb418c76a66 in switch_xml_open_root (reload=0 '\0',<br>
err=0x7fff211d1110) at src/switch_xml.c:1918<br>
event = 0x12b4b60<br>
path_buf =<br>
"/opt/freeswitch/conf/freeswitch.xml\0\0\0\0\0\340\33\"\1\0\0\0\0\0\320\34\31\264\177\0\0)'\214\30\264\177\0\0\6\0\0\0\b\0\0\1\200\247\273\30\264\177\0\0\0\0\0\0\0\0\0\0\340\33\"\1\0\0\0\0O\0\0\0\0\0\0\0\271\24\214\0\0\4\0\0`\6\35!\377\177\0\0@\16\35!\377\177\0\0\340\33\"\1\0\0\0\0\0\272\273\30\264\177\0\0p\r\35!\377\177\0\0`\v@\0\0\0\0\0<br>
\26\35!\377\177", '\0' <repeats 18 times>,<br>
"v\202\214\30\264\177\0\0\71\0\0\0\0\0\0\0\224\t\307\30\264\177\0\0\65\2\0\0\60\0\0\0\200\0\0\0\377\177\0\0\6\0\325\30\264\177\0\0\263\352\16\0\377\177\0\0\320\v\35!\377"...<br>
hasmain = 0 '\0'<br>
errcnt = 0 '\0'<br>
new_main = 0x1221ca0<br>
r = 0x0<br>
__func__ = "switch_xml_open_root"<br>
#8 0x00007fb418c76b5e in switch_xml_init (pool=0x126aff8,<br>
err=0x7fff211d1110) at src/switch_xml.c:1945<br>
xml = 0x12b8338<br>
__PRETTY_FUNCTION__ = "switch_xml_init"<br>
---Type <return> to continue, or q <return> to quit---<br>
#9 0x00007fb418c2d78f in switch_core_init (flags=1,<br>
console=SWITCH_TRUE, err=0x7fff211d1110) at src/switch_core.c:1231<br>
uuid = {data = "\0\0\0\0\0\0\0\0\200\247\273\30\264\177\0"}<br>
guess_ip = "::1\0\61\66\70.69.69", '\0' <repeats 187<br>
times>"\331,<br>
_\222\30\264\177\0\0\0\0\0\0\0\0\0\0\25\0\0\0\0\0\0\0\0\320\34\31\264\177\0\0\25",<br>
'\0' <repeats 15 times>, "J\30\214\30\264\177\0"<br>
dir_path = 0x0<br>
mask = 16777215<br>
in = {s_addr = 16777215}<br>
__PRETTY_FUNCTION__ = "switch_core_init"<br>
#10 0x00007fb418c2e02b in switch_core_init_and_modload (flags=1,<br>
console=SWITCH_TRUE, err=0x7fff211d1110) at src/switch_core.c:1422<br>
event = 0x400b60<br>
__func__ = "switch_core_init_and_modload"<br>
#11 0x0000000000400ed7 in main (argc=1, argv=0x7fff211d1628) at main.c:97<br>
flags = 1<br>
err = 0x7fb418d56314 "Success"<br>
console = SWITCH_TRUE<br>
destroy_status = SWITCH_STATUS_SUCCESS<br>
ret = 0<br>
__PRETTY_FUNCTION__ = "main"<br>
<br>
Thread 3 (Thread 31288):<br>
#0 0x00007fb417ff92e9 in pthread_cond_wait@@GLIBC_2.3.2 () from<br>
/lib/libpthread.so.0<br>
No symbol table info available.<br>
#1 0x00007fb418ca13ef in apr_thread_cond_wait (cond=0x14dbb08,<br>
mutex=0x14dbab8) at locks/unix/thread_cond.c:68<br>
rv = 0<br>
#2 0x00007fb418c94c1f in apr_queue_pop (queue=0x14dba78,<br>
data=0x7fb41676c0b8) at misc/apr_queue.c:276<br>
rv = 0<br>
#3 0x00007fb418c045ca in switch_queue_pop (queue=0x14dba78,<br>
data=0x7fb41676c0b8) at src/switch_apr.c:902<br>
No locals.<br>
#4 0x00007fb418c3ba5e in switch_event_thread (thread=0x1663ac8,<br>
obj=0x14dba78) at src/switch_event.c:289<br>
pop = 0x0<br>
event = 0x0<br>
queue = 0x14dba78<br>
index = 0<br>
my_id = 1<br>
__func__ = "switch_event_thread"<br>
#5 0x00007fb418ca8c01 in dummy_worker (opaque=0x1663ac8) at<br>
threadproc/unix/thread.c:138<br>
thread = 0x1663ac8<br>
#6 0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0<br>
No symbol table info available.<br>
#7 0x00007fb418933fcd in clone () from /lib/libc.so.6<br>
No symbol table info available.<br>
#8 0x0000000000000000 in ?? ()<br>
No symbol table info available.<br>
<br>
Thread 2 (Thread 31289):<br>
#0 0x00007fb417ff92e9 in pthread_cond_wait@@GLIBC_2.3.2 () from<br>
/lib/libpthread.so.0<br>
No symbol table info available.<br>
#1 0x00007fb418ca13ef in apr_thread_cond_wait (cond=0x159fb18,<br>
mutex=0x159fac8) at locks/unix/thread_cond.c:68<br>
rv = 0<br>
#2 0x00007fb418c94c1f in apr_queue_pop (queue=0x159fa88,<br>
data=0x7fb4167a80b8) at misc/apr_queue.c:276<br>
rv = 0<br>
#3 0x00007fb418c045ca in switch_queue_pop (queue=0x159fa88,<br>
data=0x7fb4167a80b8) at src/switch_apr.c:902<br>
No locals.<br>
#4 0x00007fb418c3ba5e in switch_event_thread (thread=0x1663af8,<br>
obj=0x159fa88) at src/switch_event.c:289<br>
---Type <return> to continue, or q <return> to quit---<br>
pop = 0x0<br>
event = 0x0<br>
queue = 0x159fa88<br>
index = 0<br>
my_id = 2<br>
__func__ = "switch_event_thread"<br>
#5 0x00007fb418ca8c01 in dummy_worker (opaque=0x1663af8) at<br>
threadproc/unix/thread.c:138<br>
thread = 0x1663af8<br>
#6 0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0<br>
No symbol table info available.<br>
#7 0x00007fb418933fcd in clone () from /lib/libc.so.6<br>
No symbol table info available.<br>
#8 0x0000000000000000 in ?? ()<br>
No symbol table info available.<br>
<br>
Thread 1 (Thread 31287):<br>
#0 0x00007fb418c94a7f in apr_queue_trypush (queue=0x7fb4168e45a8,<br>
data=0x12b4b60) at misc/apr_queue.c:215<br>
rv = 0<br>
#1 0x00007fb418c0464a in switch_queue_trypush (queue=0x7fb4168e45a8,<br>
data=0x12b4b60) at src/switch_apr.c:931<br>
s = 0<br>
#2 0x00007fb418c3bab8 in switch_event_thread (thread=0x1663a98,<br>
obj=0x12b8398) at src/switch_event.c:305<br>
pop = 0x12b4b60<br>
event = 0x12b4b60<br>
queue = 0x12b8398<br>
index = 0<br>
my_id = 0<br>
__func__ = "switch_event_thread"<br>
#3 0x00007fb418ca8c01 in dummy_worker (opaque=0x1663a98) at<br>
threadproc/unix/thread.c:138<br>
thread = 0x1663a98<br>
#4 0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0<br>
No symbol table info available.<br>
#5 0x00007fb418933fcd in clone () from /lib/libc.so.6<br>
No symbol table info available.<br>
#6 0x0000000000000000 in ?? ()<br>
No symbol table info available.<br>
<br>
<br>
FS svn r14092, gcc-4.3.3, x86_64<br>
<br>
Any idea what should I add to free up everything after shutdown and lets<br>
start with "blank list"?<br>
<br>
Thanks in advance,<br>
Tamas<br>
<br>
<br>
_______________________________________________<br>
Freeswitch-dev mailing list<br>
<a href="mailto:Freeswitch-dev@lists.freeswitch.org">Freeswitch-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>
<br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br><a href="http://iax:guest@conference.freeswitch.org/888">iax:guest@conference.freeswitch.org/888</a><br>
<a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>pstn:213-799-1400<br>