Problem with new version of media clock (clock_thread.c) PJSIP 2.0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
I think I have found a problem with the new version of the media clock
(used by the master port)

The problem:

Part1:
* in pjmedia_clock_create2( ... ) a memory pool
   is passed as an argument.
* from this pool's factory an other pool is created
  (let's call it new_pool for now)
* from new_pool the memory for the pjmedia_clock "instance"
  is "allocated" and a pointer to new_pool is stored to the instance.

so far everything looks good.
Part2:

in pjmedia_clock_start the clock thread is created from
new_pool (and started)


Part3: this is the point where the error occures

in pjmedia_clock_stop the quitting flag is set to true
and the thread is joined.

the problem:
   * after joining pj_thread_destroy should be called to destroy the
thread's mutex.
   * the memory allocated from new_pool is lost now because if you restart
the
      clock (by calling pjmedia_clock_start) again new memory is
"allocated" from
      new_pool --> new_pool is growing on each restart.

If the MasterPort is enabled and disabled very often (don't know if this
happens that often) this behaviour can lead to
high memory consumption)

possible solution:

1)in pjmedia_clock_create2 use the pool passed as an argument
   to allocate memory for the pjmedia_clock instance
   but also create new_pool and store the pointer (new_pool) to the
   pjmedia_clock instance.
2) in pjmedia_clock_start create the thread from new_pool
3) in pjmedia_clock_stop:
     join the thread (like it is done now)
     but after that call pj_thread_destroy
     and pj_pool_reset(new_pool)

     ==> so the thread's mutex is destroyed + new_pool's memory usage is
not growing (when restarting) !!!

I hope this was understandable.
If you have any questions,
I will try to answer them.

mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20120526/16fd719e/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux