Forráskód Böngészése

ims_registrar_pcscf: convert to memory error log helper, add missing mem cleanup during errors

Pantelis Kolatsis 2 éve
szülő
commit
d031d1e483

+ 2 - 2
src/modules/ims_registrar_pcscf/async_reginfo.c

@@ -61,7 +61,7 @@ int init_reginfo_event_list()
 
 	reginfo_event_list = shm_malloc(sizeof(reginfo_event_list_t));
 	if (!reginfo_event_list) {
-		LM_ERR("No more SHM mem\n");
+		SHM_MEM_ERROR;
 		return 0;
 	}
 	memset(reginfo_event_list, 0, sizeof(reginfo_event_list_t));
@@ -133,7 +133,7 @@ reginfo_event_t* new_reginfo_event (int event, str *publ_body, str *publ_id, str
 	new_event = (reginfo_event_t*) shm_malloc(len);
 	
 	if (!new_event) {
-		LM_ERR("No more shm mem\n");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 	memset(new_event, 0, len);

+ 6 - 4
src/modules/ims_registrar_pcscf/sec_agree.c

@@ -33,6 +33,7 @@ static uint32_t parse_digits(str value)
     char* buf = (char*)malloc(buf_len);
 
     if(!buf) {
+        SYS_MEM_ERROR;
         return ret;
     }
 
@@ -62,6 +63,7 @@ static void trim_whitespaces(str* string) {
 #define SEC_COPY_STR_PARAM(DST, SRC)\
         DST.s = shm_malloc(SRC.len);\
         if(DST.s == NULL) {\
+            SHM_MEM_ERROR;\
             return -1;\
         }\
         memcpy(DST.s, SRC.s, SRC.len);\
@@ -130,13 +132,13 @@ static security_t* parse_sec_agree(struct hdr_field* h)
 
     // allocate shm memory for security_t (it will be saved in contact)
     if ((params = shm_malloc(sizeof(security_t))) == NULL) {
-        LM_ERR("Error allocating shm memory for security_t parameters during sec-agree parsing\n");
+        SHM_MEM_ERROR_FMT("for security_t parameters during sec-agree parsing\n");
         return NULL;
     }
     memset(params, 0, sizeof(security_t));
 
     if((params->sec_header.s = shm_malloc(h->name.len)) == NULL) {
-        LM_ERR("Error allocating shm memory for security_t sec_header parameter during sec-agree parsing\n");
+        SHM_MEM_ERROR_FMT("for security_t sec_header parameter during sec-agree parsing\n");
         goto cleanup;
     }
     memcpy(params->sec_header.s, h->name.s, h->name.len);
@@ -145,7 +147,7 @@ static security_t* parse_sec_agree(struct hdr_field* h)
     // allocate memory for ipsec_t in security_t
     params->data.ipsec = shm_malloc(sizeof(ipsec_t));
     if(!params->data.ipsec) {
-        LM_ERR("Error allocating memory for ipsec parameters during sec-agree parsing\n");
+        SHM_MEM_ERROR_FMT("for ipsec parameters during sec-agree parsing\n");
         goto cleanup;
     }
     memset(params->data.ipsec, 0, sizeof(ipsec_t));
@@ -211,7 +213,7 @@ cleanup:
     // Keep them in sync!
     if (params) {
         shm_free(params->sec_header.s);
-
+        shm_free(params->data.ipsec);
         if(params->type == SECURITY_IPSEC && params->data.ipsec) {
             shm_free(params->data.ipsec->ealg.s);
             shm_free(params->data.ipsec->r_ealg.s);

+ 2 - 2
src/modules/ims_registrar_pcscf/service_routes.c

@@ -593,7 +593,7 @@ int force_service_routes(struct sip_msg* _m, udomain_t* _d) {
 		/* Allocate the memory for this new header: */
 		new_route_header.s = pkg_malloc(new_route_header.len);
 		if (!new_route_header.s) {
-			LM_ERR("Error allocating %d bytes\n", new_route_header.len);
+			PKG_MEM_ERROR_FMT("allocating %d bytes\n", new_route_header.len);
 			goto error;
 		}
 		
@@ -734,7 +734,7 @@ int assert_called_identity(struct sip_msg* _m, udomain_t* _d) {
 		x.len = p_asserted_identity_s.len+p_asserted_identity_m.len+called_party_id.len+p_asserted_identity_e.len;
 		x.s = pkg_malloc(x.len);
 		if (!x.s){
-			LM_ERR("P_assert_called_identity: Error allocating %d bytes\n",	x.len);
+			PKG_MEM_ERROR_FMT("allocating %d bytes\n", x.len);
 			x.len=0;
 			goto error;		
 		}

+ 1 - 1
src/modules/ims_registrar_pcscf/subscribe.c

@@ -53,7 +53,7 @@ int reginfo_subscribe_real(struct sip_msg* msg, pv_elem_t* uri, str* service_rou
 	int len = strlen(P_ASSERTED_IDENTITY_HDR_PREFIX) + pcscf_uri.len + 1 + CRLF_LEN;
 	p_asserted_identity_header.s = (char *)pkg_malloc( len );
 	if ( p_asserted_identity_header.s == NULL ) {
-	    LM_ERR( "insert_asserted_identity: pkg_malloc %d bytes failed", len );
+	    SHM_MEM_ERROR_FMT("%d bytes failed", len );
 	    goto error;
 	}
 

+ 2 - 2
src/modules/ims_registrar_pcscf/ul_callback.c

@@ -156,7 +156,7 @@ str* build_reginfo_partial(ppublic_t *impu, struct pcontact* c, int type) {
 	/* create the body */
 	body = (str*) pkg_malloc(sizeof(str));
 	if (body == NULL) {
-		LM_ERR("while allocating memory\n");
+		PKG_MEM_ERROR;
 		goto error;
 	}
 	memset(body, 0, sizeof(str));
@@ -201,7 +201,7 @@ int send_partial_publish(ppublic_t *impu, struct pcontact *c, int type)
 	int len = strlen(P_ASSERTED_IDENTITY_HDR_PREFIX) + pcscf_uri.len + 1 + CRLF_LEN;
 	p_asserted_identity_header.s = (char *)pkg_malloc( len );
 	if ( p_asserted_identity_header.s == NULL ) {
-	    LM_ERR( "insert_asserted_identity: pkg_malloc %d bytes failed", len );
+	    PKG_MEM_ERROR_FMT("%d bytes failed", len );
 	    goto error;
 	}