[sr-dev] git:master:961f6bad: ims_usrloc_scscf: Do not re-use Subscription, if it's for a different IMPU

Carsten Bock carsten at ng-voice.com
Sat Jul 4 18:16:30 CEST 2015


Module: kamailio
Branch: master
Commit: 961f6bad29a8079ad26a3851ee453c1c236e9ebf
URL: https://github.com/kamailio/kamailio/commit/961f6bad29a8079ad26a3851ee453c1c236e9ebf

Author: Carsten Bock <carsten at ng-voice.com>
Committer: Carsten Bock <carsten at ng-voice.com>
Date: 2015-07-04T18:14:02+02:00

ims_usrloc_scscf: Do not re-use Subscription, if it's for a different IMPU

---

Modified: modules/ims_usrloc_scscf/impurecord.c

---

Diff:  https://github.com/kamailio/kamailio/commit/961f6bad29a8079ad26a3851ee453c1c236e9ebf.diff
Patch: https://github.com/kamailio/kamailio/commit/961f6bad29a8079ad26a3851ee453c1c236e9ebf.patch

---

diff --git a/modules/ims_usrloc_scscf/impurecord.c b/modules/ims_usrloc_scscf/impurecord.c
index c5fbc99..d996fca 100644
--- a/modules/ims_usrloc_scscf/impurecord.c
+++ b/modules/ims_usrloc_scscf/impurecord.c
@@ -774,12 +774,30 @@ void free_ims_subscription_data(ims_subscription *s) {
 
 /* Still needs to be implemented */
 int compare_subscription(ims_subscription* new, ims_subscription* orig) {
-    int i, j;
+    int i, j, k, l;
     LM_DBG("Comparing subscription for IMPI [%.*s]\n", orig->private_identity.len, orig->private_identity.s);
     for (i = 0; i < orig->service_profiles_cnt; i++) {
-
         for (j = 0; j < orig->service_profiles[i].public_identities_cnt; j++) {
-
+            for (k = 0; k < new->service_profiles_cnt; k++) {
+                for (l = 0; l < new->service_profiles[k].public_identities_cnt; l++) {
+                    LM_DBG("new %.*s (%i) vs. orig %.*s (%i)\n",
+                      new->service_profiles[k].public_identities[l].public_identity.len,
+                      new->service_profiles[k].public_identities[l].public_identity.s,
+                      new->service_profiles[k].public_identities[l].public_identity.len,
+                      orig->service_profiles[i].public_identities[j].public_identity.len,
+                      orig->service_profiles[i].public_identities[j].public_identity.s,
+                      orig->service_profiles[i].public_identities[j].public_identity.len);
+
+                    if (orig->service_profiles[i].public_identities[j].public_identity.len == 
+                      new->service_profiles[k].public_identities[l].public_identity.len) {
+                        if (memcmp(orig->service_profiles[i].public_identities[j].public_identity.s,
+                          new->service_profiles[k].public_identities[l].public_identity.s,
+                          new->service_profiles[k].public_identities[l].public_identity.len) == 0)
+                            return 1;
+                    }
+                    
+                }
+            }
         }
     }
 
@@ -828,7 +846,8 @@ int update_impurecord(struct udomain* _d, str* public_identity, impurecord_t* im
             unlock_subscription_slot(subs_ptr->sl);
         } else {
             //TODO: we may want to do a deep comparison of the subscription and update....
-            subs_ptr = subscription;
+            if (compare_subscription(subs_ptr, subscription) != 0)
+                subs_ptr = subscription;
         }
         lock_subscription(subs_ptr);
         subscription_locked = 1;
@@ -917,9 +936,11 @@ int update_impurecord(struct udomain* _d, str* public_identity, impurecord_t* im
         } else {
             LM_DBG("new subscription is the same as the old one....not doing anything");
             //check that the service profile and associated impus are in the subscription, if not, add...
-            if (compare_subscription(subs_ptr, *s) != 0) {
-                LM_WARN("TODO: There is a new service profile we need to add to the subscription\n");
-            }
+            /* if (compare_subscription(subs_ptr, *s) != 0) {
+                unref_subscription((*_r)->s); //different subscription which we don't have lock on yet.
+                ref_subscription_unsafe(subs_ptr);
+                (*_r)->s = subs_ptr;
+            }   */
         }
     }
 




More information about the sr-dev mailing list