Crash in cpool_create_pool when pjsip setup in a worker thread

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

 



On Mon, Oct 26, 2009 at 11:56 PM, Eric Chamberlain <eric at rf.com> wrote:
> Hello,
> I'm using a worker thread to startup pjsip,
> otherwise?pjsua_media_transports_create?blocks the UI for a few seconds,
> while ICE is initialized.

Yeah.

> The thread calls: pjsip_create(),?pjsua_pool_create(), etc.
> When the thread is done, it ends. ?The main thread is then registered with
> pjsip.

That's probably the part where pjlib doesn't like it. Main thread (the
thread that calls pj_init()) is treated differently, i.e. it's thread
descriptor is kept alive in a global variable and is never destroyed.
If the thread itself is terminated, there may be something that goes
out of sync.

> When a call is made (about one out of three calls) and?pjsua_verify_sip_url
> is called (from the main thread), the application crashes in
> cpool_create_pool with an EXEC_BAD_ACCESS.
> Am I doing something wrong? ?Do I have to initialize pjsip from the main
> thread? ?If so, can?pjsua_media_transports_create be called from a worker
> thread?

You should be able to, and that's probably the best option, i.e. to
initialize pjsip from the main thread, and call
pjsua_media_transports() from the worker thread, terminating the
worker thread if necessary after the function call completes.

> Can pjsip be initialized in a worker thread that ends after the
> initialization is done?

I'm not sure, I never tried this. Probably it can't, based on above.

> Do I have to keep the worker thread around

Depends. If this is the main thread then probably yes you'd have to.

> and call pjsua_verify_sip_url from the worker thread?

Definitely no. Once threads are setup you can call the API from any threads.

Cheers
 Benny



[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