On 4/27/06, Thomas Rosenblatt <[EMAIL PROTECTED]> wrote:
> > Why the cache->cache_home is not put to su_home_threading in the
> > function sres_cache_new ?
> > Does the problems with multi threading come from that?

That sounds plausible.

> Indeed, I've add this line in sres_cache_new, and a UNLOCK(cache) in
> sres_cache_store() just after the call to _sres_cache_free_one(cache, or); !

I guess there was also LOCK(cache) missing in sres_cache_store()?
This is my patch:

diff -rN -udp old-sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c
new-sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c
--- old-sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c  2006-04-27
20:07:32.000000000 +0300
+++ new-sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c  2006-04-27
20:07:32.000000000 +0300
@@ -138,9 +138,11 @@ sres_cache_t *sres_cache_new(int n)
 {
   sres_cache_t *cache = su_home_new(sizeof *cache);

-  if (cache)
+  if (cache) {
+    su_home_threadsafe(cache->cache_home);
     if (sres_htable_resize(cache->cache_home, cache->cache_hash, n) < 0)
       su_home_unref(cache->cache_home), cache = NULL;
+  }

   return cache;
 }
@@ -282,11 +284,13 @@ sres_cache_store(sres_cache_t *cache, sr
   if (rr == NULL)
     return;

+  hash = sres_hash_key(rr->sr_name);
+
+  LOCK(cache);
+
   if (sres_htable_is_full(cache->cache_hash))
     sres_htable_resize(cache->cache_home, cache->cache_hash, 0);

-  hash = sres_hash_key(rr->sr_name);
-
   for (rr_iter = sres_htable_hash(cache->cache_hash, hash);
        (rr_hash_entry = *rr_iter);
        rr_iter = sres_htable_next(cache->cache_hash, rr_iter)) {
@@ -313,6 +317,9 @@ sres_cache_store(sres_cache_t *cache, sr
     rr->sr_refcount++;

     _sres_cache_free_one(cache, or);
+
+    UNLOCK(cache);
+
     return;
   }

@@ -327,6 +334,8 @@ sres_cache_store(sres_cache_t *cache, sr
   }

   *rr_iter = rr_hash_entry;
+
+  UNLOCK(cache);
 }

 /** Free the list records. */

> And now it is working, except that sometimes the su_root_break() does
> not break su_root_run, and I do not know why!

We do not have any decent multithreading test for sresolv. wink wink
nudge nudge ;)

--
Pekka.Pessi mail at nokia.com


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to