unregistered external thread

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

 



I agree about thread safety, but in my case there is only one thread
that enters it's thread function, so I don't see problems in that(in my
case). Anyway I still have problem with that, but it's probably my
problem. I'll try to find it out.

 

Best regards,

Ilya  

________________________________

From: pjsip-bounces@xxxxxxxxxxxxxxx
[mailto:pjsip-bounces at lists.pjsip.org] On Behalf Of Jim Gomes
Sent: Monday, April 27, 2009 9:19 PM
To: pjsip list
Subject: Re: unregister external thread

 

I would like to point out that the implementation used below is not
thread safe.  To use static variables in such a manner is incorrect.  To
be thread-safe, it is necessary to use thread local variables.  I submit
the following function for use in the public domain.  It can and should
be called before any PJSIP functions are called by a thread:

 

/*

 * pj_thread_auto_register(void)

 */

PJ_DEF(pj_status_t) pj_thread_auto_register(void)

{

    pj_status_t rc;

 

    if(!pj_thread_is_registered())

    {

      pj_tls_var(pj_thread_desc) rpc_thread_desc;

      pj_thread_t* thread_ptr;

 

      rc = pj_thread_register("auto_thr%p", rpc_thread_desc,
&thread_ptr);

    }

    else

    {

      rc = PJ_SUCCESS;

    }

 

    return rc;

}

 

 

Regards,

Jim Gomes

 

From: pjsip-bounces@xxxxxxxxxxxxxxx
[mailto:pjsip-bounces at lists.pjsip.org] On Behalf Of Ilya Kalinin
Sent: Sunday, 26 April, 2009 1:53 AM
To: pjsip list
Subject: Re: unregister external thread

 

Oh, this happens then I call for pj_thread_sleep() within the thread
functions

________________________________

From: pjsip-bounces@xxxxxxxxxxxxxxx
[mailto:pjsip-bounces at lists.pjsip.org] On Behalf Of Ilya Kalinin
Sent: Sunday, April 26, 2009 11:50 AM
To: pjsip at lists.pjsip.org
Subject: unregister external thread

 

Hi, I using simple wrapper on pj_thread functions, to create threads in
my application. I also always add this magic code to the thread
functions:

    static pj_thread_desc desc;

    static pj_thread_t *thread;

 

    if(!pj_thread_is_registered()) {

        pj_thread_register(NULL,desc,&thread);

    }

 

It worked fine with 1.0rc2, but with 1.0.1 I get the old error:

 

11:35:32.936 os_core_win32.  pjlib 1.0.1 for win32 initialized

EstablishAssertion failed: !"Calling pjlib from unknown/external thread.
You mus

t " "register external threads with pj_thread_register() " "before
calling any p

jlib functions.", file
e:\work\pjproject-wince-1.0.1\pjlib\src\pj\os_core_win32.

c, line 522

ed call.

Assertion failed: mutex->owner == pj_thread_this(), file
e:\work\pjproject-wince

-1.0.1\pjlib\src\pj\os_core_win32.c, line 945

 

What can be the problem?

 

Best regards,

Ilya

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090428/3901ca78/attachment-0001.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