Просмотр исходного кода

modules/ims_usrloc_scscf,modules/ims_registrar_scscf: impus as string from subscription can be created in pkg or shm depending on argument passed

jaybeepee 9 лет назад
Родитель
Сommit
a15affa4d5

+ 2 - 2
modules/ims_registrar_scscf/registrar_notify.c

@@ -471,7 +471,7 @@ int event_reg(udomain_t* _d, impurecord_t* r_passed, int event_type, str *presen
 
             //get IMPU set from the presentity's subscription
             res = ul.get_impus_from_subscription_as_string(_d, r,
-                    0/*all unbarred impus*/, &impu_list, &num_impus);
+                    0/*all unbarred impus*/, &impu_list, &num_impus, 0/*pkg*/);
             if (res != 0) {
                 LM_WARN("failed to get IMPUs from subscription\n");
                 ul.unlock_udomain(_d, presentity_uri);
@@ -512,7 +512,7 @@ int event_reg(udomain_t* _d, impurecord_t* r_passed, int event_type, str *presen
 
             //this is a ulcallback so r_passed domain is already locked
             res = ul.get_impus_from_subscription_as_string(_d, r_passed,
-                    0/*all unbarred impus*/, &impu_list, &num_impus);
+                    0/*all unbarred impus*/, &impu_list, &num_impus, 0/*pkg*/);
             if (res != 0) {
                 LM_WARN("failed to get IMPUs from subscription\n");
                 if (impu_list) {

+ 10 - 3
modules/ims_usrloc_scscf/udomain.c

@@ -626,7 +626,7 @@ int delete_impurecord(udomain_t* _d, str* _aor, struct impurecord* _r) {
  * barring-(-1) get all records
  * NB. Remember to free the block of memory pointed to by impus (pkg_malloc)
  */
-int get_impus_from_subscription_as_string(udomain_t* _d, impurecord_t* impu_rec, int barring, str** impus, int* num_impus) {
+int get_impus_from_subscription_as_string(udomain_t* _d, impurecord_t* impu_rec, int barring, str** impus, int* num_impus, int is_shm) {
     int i, j, count;
     *num_impus = 0;
     *impus = 0;
@@ -669,9 +669,16 @@ int get_impus_from_subscription_as_string(udomain_t* _d, impurecord_t* impu_rec,
     LM_DBG("num of records returned is %d and we need %d bytes\n", *num_impus, bytes_needed);
 
     len = (sizeof (str)*(*num_impus)) + bytes_needed;
-    *impus = (str*) pkg_malloc(len); //TODO: rather put this on the stack... dont' fragment pkg....
+    if (is_shm)
+        *impus = (str*) shm_malloc(len); 
+    else 
+        *impus = (str*) pkg_malloc(len); //TODO: rather put this on the stack... dont' fragment pkg....
+    
     if (*impus == 0) {
-        LM_ERR("no more pkg_mem\n");
+        if (is_shm)
+            LM_ERR("no more shm_mem\n");
+        else 
+            LM_ERR("no more pkg_mem\n");
         return 1;
     }
     char* ptr = (char*) (*impus + *num_impus);

+ 1 - 1
modules/ims_usrloc_scscf/udomain.h

@@ -226,7 +226,7 @@ int delete_impurecord(udomain_t* _d, str* _aor, struct impurecord* _r);
  * barring-0 get all unbarred
  * barring-(-1) get all records
  */
-int get_impus_from_subscription_as_string(udomain_t* _d, impurecord_t* impu_rec, int barring, str** impus, int* num_impus);
+int get_impus_from_subscription_as_string(udomain_t* _d, impurecord_t* impu_rec, int barring, str** impus, int* num_impus, int is_shm);
 
 int get_subscription(str* impi_s, ims_subscription** s, int leave_slot_locked);
 void add_subscription(ims_subscription* s);

+ 1 - 1
modules/ims_usrloc_scscf/usrloc.h

@@ -496,7 +496,7 @@ typedef int (*get_subscriber_t)(impurecord_t* urec, str *watcher_contact, str *p
 typedef int (*add_subscriber_t)(impurecord_t* urec,
 		subscriber_data_t* subscriber_data, reg_subscriber** _reg_subscriber, int db_load);
 
-typedef int (*get_impus_from_subscription_as_string_t)(udomain_t* _d, impurecord_t* impu_rec, int barring, str** impus, int* num_impus);
+typedef int (*get_impus_from_subscription_as_string_t)(udomain_t* _d, impurecord_t* impu_rec, int barring, str** impus, int* num_impus, int is_shm);
 
 typedef str (*get_presentity_from_subscriber_dialog_t)(str *callid, str *to_tag, str *from_tag);