<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
One more clarification please :<br>
<br>
In order for my thread to use the session data before the session is
destroyed I am using<br>
my own mutex and condition signal. e.g.<br>
<br>
(pseudo code follows) :<br>
<br>
thread_function(switch_thread_t *thread, void *ptr){ <br>
<br>
// the pointer ptr is a struct that contains a pointer to session,the
mutex and condition created in the calling thread<br>
<br>
(session dependend stuff)<br>
<br>
switch_thread_cond_signal(sth-&gt;cond); //sends signal to calling
thread that we stopped using the session so it can exit<br>
<br>
(session independent stuff)<br>
<br>
}<br>
calling_function(switch_core_session_t *session){<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; (init stuff)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch_mutex_init(&amp;thread_params-&gt;mutex,
SWITCH_MUTEX_NESTED, pool);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch_thread_cond_create(&amp;thread_params-&gt;cond, pool);<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; (thread creation stuff)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch_mutex_lock( thread_params-&gt;mutex );<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch_thread_cond_wait(thread_params-&gt;cond,
thread_params-&gt;mutex); // this is were the calling thread waits for
a signal<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch_mutex_unlock( thread_params-&gt;mutex );<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return SWITCH_STATUS_SUCCESS;<br>
<br>
}<br>
<br>
Is the above correct? Is there another way to create a "wait" state for
the calling thread until the child thread <br>
is done with the session data?<br>
<br>
<br>
<br>
<br>
Apostolos Pantsiopoulos wrote:
<blockquote cite="mid:4981C7A0.7090000@kinetix.gr" type="cite">
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
Thanks for the explanations (both Anthony and Michael).<br>
You both clarified the subject quite well.<br>
  <br>
Anthony Minessale wrote:
  <blockquote
 cite="mid:191c3a030901290555i58186cc8p2cdecd7b700f33dc@mail.gmail.com"
 type="cite">if your intent is to keep the data around longer than the
session in it's own thread, you will want to make a new pool <br>
and use that pool to launch the thread.&nbsp; pass the pool into the thread
as a member of your thread private data and free<br>
the pool before you exit the thread.<br>
    <br>
You cannot bring the session with you into the thread unless you read
lock the session first so it will not be destroyed while<br>
you are using it in the thread.<br>
    <br>
Be aware keeping the session around in the thread just a wild goose
chase from doing it the why it already was doing it.<br>
The session thread is already independent and it does not stop any
other call from proceeding so you may as well do all the work<br>
in your session thread in the state change handler like it already does
and just add more strict timeout.<br>
&nbsp;<br>
    <br>
    <div class="gmail_quote">On Thu, Jan 29, 2009 at 7:23 AM, Apostolos
Pantsiopoulos <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:regs@kinetix.gr">regs@kinetix.gr</a>&gt;</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;">
      <div bgcolor="#ffffff" text="#000000">The question is : which
pool
should I use for each different thing I am
trying to accomplish?<br>
      <br>
For instance the code below is part of my mod_radius_cdr
experimentation.<br>
When I am making use of a pool within a module should I :<br>
      <br>
a) create a new pool?<br>
b) make use of an existing one?<br>
c) what kind of pool should I use?<br>
d) is it really just one pool (accessed through different handlers) and
I am making myself look like a fool so far?
      <div>
      <div class="Wj3C7c"><br>
      <br>
      <br>
      <br>
      <br>
      <br>
Michael Jerris wrote:
      <blockquote type="cite">
        <pre>I am not sure even after re-reading what your question is, could you  
try to rephrase?

Mike

On Jan 29, 2009, at 8:00 AM, Apostolos Pantsiopoulos wrote:

  </pre>
        <blockquote type="cite">
          <pre>I found it out by myself!
(why is it that we always come with the solution right after posting  
to
the list?)

I inserted :

thread_params = switch_core_session_alloc(session,  
sizeof(*thread_params));

before the pool initialization.

But still,  can I get some answers to the questions bellow about
how to effectively handle memory allocations?



Apostolos Pantsiopoulos wrote:
    </pre>
          <blockquote type="cite">
            <pre>I have the code below :

struct radacct_thread_handle {
       switch_core_session_t *session;
       switch_mutex_t *mutex;
       switch_thread_cond_t *cond;
};

static switch_status_t my_on_routing(switch_core_session_t *session){

       switch_thread_t *thread;
       switch_threadattr_t *thd_attr = NULL;

       switch_memory_pool_t *pool;

       struct radacct_thread_handle *thread_params = NULL;

       pool = switch_core_session_get_pool(session);

       thread_params-&gt;session = session;

       ...

}

when the program reaches the last line (thread_params-&gt;session =  
session;)
I get a core dump. Is this a memory allocation error? Is it because  
I am
making
use of the wrong pool? Please enlighten me because I am not an  
experienced c
programmer, and I am struggling to get familiar with the FS API.


      </pre>
          </blockquote>
        </blockquote>
        <pre>_______________________________________________
Freeswitch-dev mailing list
<a moz-do-not-send="true"
 href="mailto:Freeswitch-dev@lists.freeswitch.org" target="_blank">Freeswitch-dev@lists.freeswitch.org</a>
<a moz-do-not-send="true"
 href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev"
 target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a>
UNSUBSCRIBE:<a moz-do-not-send="true"
 href="http://lists.freeswitch.org/mailman/options/freeswitch-dev"
 target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a>
<a moz-do-not-send="true" href="http://www.freeswitch.org"
 target="_blank">http://www.freeswitch.org</a>
  </pre>
      </blockquote>
      <br>
      <br>
      </div>
      </div>
      <div class="Ih2E3d">
      <pre cols="72">-- 
-------------------------------------------
Apostolos Pantsiopoulos
Kinetix Tele.com R &amp; D
email: <a moz-do-not-send="true" href="mailto:regs@kinetix.gr"
 target="_blank">regs@kinetix.gr</a>
------------------------------------------- </pre>
      </div>
      </div>
      <br>
_______________________________________________<br>
Freeswitch-dev mailing list<br>
      <a moz-do-not-send="true"
 href="mailto:Freeswitch-dev@lists.freeswitch.org">Freeswitch-dev@lists.freeswitch.org</a><br>
      <a moz-do-not-send="true"
 href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev"
 target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a moz-do-not-send="true"
 href="http://lists.freeswitch.org/mailman/options/freeswitch-dev"
 target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
      <a moz-do-not-send="true" href="http://www.freeswitch.org"
 target="_blank">http://www.freeswitch.org</a><br>
      <br>
    </blockquote>
    </div>
    <br>
    <br clear="all">
    <br>
-- <br>
Anthony Minessale II<br>
    <br>
FreeSWITCH <a moz-do-not-send="true" href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>
ClueCon <a moz-do-not-send="true" href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>
    <br>
AIM: anthm<br>
    <a moz-do-not-send="true"
 href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>
GTALK/JABBER/<a moz-do-not-send="true"
 href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a moz-do-not-send="true" href="http://irc.freenode.net">irc.freenode.net</a>
#freeswitch<br>
    <br>
FreeSWITCH Developer Conference<br>
    <a moz-do-not-send="true"
 href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br>
    <a moz-do-not-send="true"
 href="http://iax:guest@conference.freeswitch.org/888">iax:guest@conference.freeswitch.org/888</a><br>
    <a moz-do-not-send="true"
 href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>
pstn:213-799-1400<br>
    <pre wrap=""><hr size="4" width="90%">
_______________________________________________
Freeswitch-dev mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:Freeswitch-dev@lists.freeswitch.org">Freeswitch-dev@lists.freeswitch.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a>
UNSUBSCRIBE:<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://www.freeswitch.org">http://www.freeswitch.org</a>
  </pre>
  </blockquote>
  <br>
  <br>
  <pre class="moz-signature" cols="72">-- 
-------------------------------------------
Apostolos Pantsiopoulos
Kinetix Tele.com R &amp; D
email: <a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:regs@kinetix.gr">regs@kinetix.gr</a>
------------------------------------------- </pre>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Freeswitch-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Freeswitch-dev@lists.freeswitch.org">Freeswitch-dev@lists.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a>
UNSUBSCRIBE:<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a>
  </pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">-- 
-------------------------------------------
Apostolos Pantsiopoulos
Kinetix Tele.com R &amp; D
email: <a class="moz-txt-link-abbreviated" href="mailto:regs@kinetix.gr">regs@kinetix.gr</a>
------------------------------------------- </pre>
</body>
</html>