pjsip_endpt_handle_events

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

 



Here's a function to automatically register a thread if it isn't already 
registered. Note the caveat on using calloc. - Bill

/*
* pj_thread_auto_register(void)
* Provided by Jim Gomes on pjsip forum
* Note, here we use calloc to allocated storage for thread description
* without freeing the descriptors. This leaks 256 bytes per thread 
registration.
*/
static PJ_DEF(pj_status_t) pj_thread_auto_register(void)
{
     pj_status_t rc;

     if (!pj_thread_is_registered())
     {
         pj_thread_desc *p_thread_desc;
         pj_thread_t* thread_ptr;
         p_thread_desc = (pj_thread_desc *) calloc(1, 
sizeof(pj_thread_desc));
         rc = pj_thread_register("auto_thr%p", *p_thread_desc, &thread_ptr);
     }
     else
     {
         rc = PJ_SUCCESS;
     }
     return rc;
}


On 9/21/2015 7:27 PM, Mike Roberts wrote:
> Ah, I believe this is because I need to register the thread. Is there 
> an example on how to fill out the pj_thread_t? I created the thread 
> using webrtc.org <http://webrtc.org>'s abstraction layer so I'm not 
> sure how to fill out the struct.
>
> On Mon, Sep 21, 2015 at 4:05 PM, Mike Roberts <mike at switch.co 
> <mailto:mike at switch.co>> wrote:
>
>     Hey all,
>
>     I'm trying to create a separate thread to poll
>     pjsip_endpt_handle_events but I get an error at PJ_CHECK_STACK
>     when I first call that function from the thread. I create the
>     thread after I've initialized that library as best I can tell, is
>     there some other limitation here?
>
>     Thanks,
>     Mike
>
>
>
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20150921/285e7b8d/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