On date Tuesday 2010-04-27 12:38:53 +0200, Stefano Sabatini phoned this: > On date Tuesday 2010-04-27 10:21:27 +0100, Dan O'Donovan phoned this: > > Hi Stefano > > > > Would it be possible for you to implement a reference counter in the object > > that your nua handle magic is pointing to? > > You would need to be sure to increment/decrement it in a thread-safe way of > > course. > > Then, only free the nua handle magic when your reference counter has reached > > 0. > > > > This would be similar to what Sofia does for the memory associated with the > > nua handles themselves. > > That was another attempt, I was using nua_magic_t to store an index > containing a reference to an object from a thread-safe collection, and > it seemed to work fine but for the fact that I was doing the unsafe > cast void * <-> unsigned int. > > In other words I was putting an unique integer identifier in the magic > of the nua_handle: > nua_handle_t *handle = nua_handle(nua, (void *)an_unsigned_int, ta_tags(ta)); > > and extracting that index from the nua_magic when dealing with the nua > handle in the sofia nua event callback. > > Note that the unsafe conversion problem maybe would be addressable > by allowing to define NUA_HANDLE_MAGIC_T like the type of the > object effectively stored in the nua handle magic, e.g.: > #define NUA_HANDLE_MAGIC_T (struct hairy_weird_stuff *) > or: > #define NUA_HANDLE_MAGIC_T (unsigned int) > > rather than the type of the object *pointed to* by the magic: > #define NUA_HANDLE_MAGIC_T struct hairy_weird_stuff
Follow up: I fixed the problem in the application I wrote by making the sofia-sip thread destroy the handle, rather than delegating another thread to do it. Regards. ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Sofia-sip-devel mailing list Sofia-sip-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel