[pjsip] Thread creations and terminations

Benny Prijono bennylp at pjsip.org
Mon Nov 19 06:45:25 EST 2007


buldozer at aufbix.org wrote:
>  Hello,
> 
>  I came across a new problem with my pjsua-lib based application. The program
> has to write some data to the database from within a callback (in my case from
> on_call_state). As the program is DAO based, I came across a problem. Well, if
> you want to use DAO databases, every thread should AfxDaoInit() before doing
> anything with the database, and AfxDaoTerm(), before terminating a thread. Now
> a problem arises - if I try to use the database from within a callback, that is
> inside a different thread from the rest of a program. So - I thought it would be
> nice to have something like on_thread_create (which would be called from a newly
> created thread just after it has been created) and on_thread_terminate (called
> from the thread, which is about to be terminated). To make it even nicer - it'd
> be good to have this functionality within pjsua-lib.

Hi Toni,

What if, instead of using callback, you put a flag in the thread, to 
mark whether the thread has been DAO initialized or not. This can be 
done in application code without needing to modify pjlib's code. 
Have a look at thread local storage API (you can use Windows's or 
pjlib's).

cheers,
  -benny


>  If someone (Benny?) would point me to the parts where the threads get created
> and terminated, I wouldn't mind writing the code.
> 
> 
>  Greets, Toni






More information about the pjsip mailing list