Module: sip-router
Branch: master
Commit: 5f1e2caac5e6d68629a1a0956861bf7da6e05e31
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5f1e2caac5e6d68629a1a0956861bf7da6e05e31

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Tue Jan  3 18:02:39 2012 +0100

pua: is_dialog() returns 1 if there is a temporary dialog

- reported by Laura Testi

---

 modules_k/pua/hash.c   |   14 +++++++++++---
 modules_k/pua/pua_db.c |    6 +++++-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/modules_k/pua/hash.c b/modules_k/pua/hash.c
index ab8d145..85aa6fa 100644
--- a/modules_k/pua/hash.c
+++ b/modules_k/pua/hash.c
@@ -475,6 +475,9 @@ int get_record_id(ua_pres_t* dialog, str** rec_id)
        return 0;
 }
 
+/**
+ * return -1 on not found, 0 on established dialog, 1 on temporary dialog
+ */
 int is_dialog(ua_pres_t* dialog)
 {
        int ret_code= 0;
@@ -488,10 +491,15 @@ int is_dialog(ua_pres_t* dialog)
        hash_code= core_hash(dialog->pres_uri, dialog->watcher_uri, HASH_SIZE);
        lock_get(&HashT->p_records[hash_code].lock);
 
-       if(get_dialog(dialog, hash_code)== NULL)
-               ret_code= -1;
-       else
+       if(get_dialog(dialog, hash_code)==NULL)
+       {
+               if(get_temporary_dialog(dialog, hash_code)==NULL)
+                       ret_code= -1;
+               else
+                       ret_code= 1;
+       } else {
                ret_code= 0;
+       }
        lock_release(&HashT->p_records[hash_code].lock);
        
        return ret_code;
diff --git a/modules_k/pua/pua_db.c b/modules_k/pua/pua_db.c
index 54e11c0..44c5fbc 100644
--- a/modules_k/pua/pua_db.c
+++ b/modules_k/pua/pua_db.c
@@ -761,7 +761,11 @@ int is_dialog_puadb(ua_pres_t *pres)
                /* no need to return here - drop thro */
        }
 
-       return(0);
+       /* established dialog */
+       if(pres->to_tag.len>0)
+               return 0;
+       /* temporary dialog */
+       return 1;
 }
 
 
/******************************************************************************/


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to