Browse Source

uac: convert to memory logging helper

Henning Westerholt 5 years ago
parent
commit
9a132d30fa

+ 3 - 3
src/modules/uac/auth.c

@@ -59,7 +59,7 @@ static struct uac_credential *crd_list = 0;
 		_strd.s = (char*)pkg_malloc(_strs.len); \
 		_strd.s = (char*)pkg_malloc(_strs.len); \
 		if (_strd.s==0) \
 		if (_strd.s==0) \
 		{ \
 		{ \
-			LM_ERR("no more pkg memory\n");\
+			PKG_MEM_ERROR;\
 			goto _error; \
 			goto _error; \
 		} \
 		} \
 		memcpy( _strd.s, _strs.s, _strs.len); \
 		memcpy( _strd.s, _strs.s, _strs.len); \
@@ -112,7 +112,7 @@ int add_credential( unsigned int type, void *val)
 	crd = (struct uac_credential*)pkg_malloc(sizeof(struct uac_credential));
 	crd = (struct uac_credential*)pkg_malloc(sizeof(struct uac_credential));
 	if (crd==0)
 	if (crd==0)
 	{
 	{
-		LM_ERR("no more pkg mem\n");
+		PKG_MEM_ERROR;
 		goto error;
 		goto error;
 	}
 	}
 	memset( crd, 0, sizeof(struct uac_credential));
 	memset( crd, 0, sizeof(struct uac_credential));
@@ -341,7 +341,7 @@ static inline int apply_urihdr_changes( struct sip_msg *req,
 	req->new_uri.s = (char*)pkg_malloc(uri->len+1);
 	req->new_uri.s = (char*)pkg_malloc(uri->len+1);
 	if (req->new_uri.s==0)
 	if (req->new_uri.s==0)
 	{
 	{
-		LM_ERR("no more pkg\n");
+		PKG_MEM_ERROR;
 		goto error;
 		goto error;
 	}
 	}
 	memcpy( req->new_uri.s, uri->s, uri->len);
 	memcpy( req->new_uri.s, uri->s, uri->len);

+ 1 - 1
src/modules/uac/auth_hdr.c

@@ -340,7 +340,7 @@ str* build_authorization_hdr(int code, str *uri,
 	_uac_auth_hdr.s = (char*)pkg_malloc( len + 1);
 	_uac_auth_hdr.s = (char*)pkg_malloc( len + 1);
 	if (_uac_auth_hdr.s==0)
 	if (_uac_auth_hdr.s==0)
 	{
 	{
-		LM_ERR("no more pkg mem\n");
+		PKG_MEM_ERROR;
 		goto error;
 		goto error;
 	}
 	}
 
 

+ 9 - 9
src/modules/uac/replace.c

@@ -217,7 +217,7 @@ static inline struct lump* get_display_anchor(struct sip_msg *msg,
 	}
 	}
 	p1 = (char*)pkg_malloc(1);
 	p1 = (char*)pkg_malloc(1);
 	if (p1==0) {
 	if (p1==0) {
-		LM_ERR("no more pkg mem \n");
+		PKG_MEM_ERROR;
 		return 0;
 		return 0;
 	}
 	}
 	*p1 = '>';
 	*p1 = '>';
@@ -333,7 +333,7 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri,
 			buf.s = pkg_malloc( display->len + 2 );
 			buf.s = pkg_malloc( display->len + 2 );
 			if (buf.s==0)
 			if (buf.s==0)
 			{
 			{
-				LM_ERR("no more pkg mem\n");
+				PKG_MEM_ERROR;
 				goto error;
 				goto error;
 			}
 			}
 			memcpy( buf.s, display->s, display->len);
 			memcpy( buf.s, display->s, display->len);
@@ -370,7 +370,7 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri,
 	p = pkg_malloc( uri->len);
 	p = pkg_malloc( uri->len);
 	if (p==0)
 	if (p==0)
 	{
 	{
-		LM_ERR("no more pkg mem\n");
+		PKG_MEM_ERROR;
 		goto error;
 		goto error;
 	}
 	}
 	memcpy( p, uri->s, uri->len);
 	memcpy( p, uri->s, uri->len);
@@ -510,7 +510,7 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri,
 		param.s = (char*)pkg_malloc(param.len);
 		param.s = (char*)pkg_malloc(param.len);
 		if (param.s==0)
 		if (param.s==0)
 		{
 		{
-			LM_ERR("no more pkg mem\n");
+			PKG_MEM_ERROR;
 			goto error;
 			goto error;
 		}
 		}
 		p = param.s;
 		p = param.s;
@@ -594,7 +594,7 @@ int restore_uri( struct sip_msg *msg, str *rr_param, str* restore_avp,
 	add_to_rr.s = pkg_malloc(bsize);
 	add_to_rr.s = pkg_malloc(bsize);
 	if ( add_to_rr.s==0 ) {
 	if ( add_to_rr.s==0 ) {
 		add_to_rr.len = 0;
 		add_to_rr.len = 0;
-		LM_ERR("no more pkg mem\n");
+		PKG_MEM_ERROR;
 		goto failed;
 		goto failed;
 	}
 	}
 	add_to_rr.len = snprintf(add_to_rr.s, bsize, ";%.*s=%.*s",
 	add_to_rr.len = snprintf(add_to_rr.s, bsize, ";%.*s=%.*s",
@@ -696,7 +696,7 @@ int restore_uri( struct sip_msg *msg, str *rr_param, str* restore_avp,
 	/* duplicate the decoded value */
 	/* duplicate the decoded value */
 	p = pkg_malloc( new_uri.len);
 	p = pkg_malloc( new_uri.len);
 	if (p==0) {
 	if (p==0) {
-		LM_ERR("no more pkg mem\n");
+		PKG_MEM_ERROR;
 		goto failed;
 		goto failed;
 	}
 	}
 	memcpy( p, new_uri.s, new_uri.len);
 	memcpy( p, new_uri.s, new_uri.len);
@@ -776,7 +776,7 @@ static inline int restore_uri_reply(struct sip_msg *rpl,
 
 
 	new_val.s = pkg_malloc( len );
 	new_val.s = pkg_malloc( len );
 	if (new_val.s==0) {
 	if (new_val.s==0) {
-		LM_ERR("no more pkg mem\n");
+		PKG_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	memcpy( new_val.s, p, len);
 	memcpy( new_val.s, p, len);
@@ -945,7 +945,7 @@ static void replace_callback(struct dlg_cell *dlg, int type,
 	/* duplicate the decoded value */
 	/* duplicate the decoded value */
 	p = pkg_malloc( new_uri->len);
 	p = pkg_malloc( new_uri->len);
 	if (!p) {
 	if (!p) {
-		LM_ERR("no more pkg mem\n");
+		PKG_MEM_ERROR;
 		return;
 		return;
 	}
 	}
 	memcpy( p, new_uri->s, new_uri->len);
 	memcpy( p, new_uri->s, new_uri->len);
@@ -981,7 +981,7 @@ static void replace_callback(struct dlg_cell *dlg, int type,
 		/* add the new display exactly over the deleted one */
 		/* add the new display exactly over the deleted one */
 		buf.s = pkg_malloc(new_display->len + 2);
 		buf.s = pkg_malloc(new_display->len + 2);
 		if (buf.s==0) {
 		if (buf.s==0) {
-			LM_ERR("no more pkg mem\n");
+			PKG_MEM_ERROR;
 			goto free;
 			goto free;
 		}
 		}
 		memcpy( buf.s, new_display->s, new_display->len);
 		memcpy( buf.s, new_display->s, new_display->len);

+ 10 - 10
src/modules/uac/uac_reg.c

@@ -163,7 +163,7 @@ int reg_active_init(int mode)
 	}
 	}
 	reg_active = (int*)shm_malloc(sizeof(int));
 	reg_active = (int*)shm_malloc(sizeof(int));
 	if(reg_active==NULL) {
 	if(reg_active==NULL) {
-		LM_ERR("not enough shared memory\n");
+		SHM_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	*reg_active = mode;
 	*reg_active = mode;
@@ -190,7 +190,7 @@ int uac_reg_init_ht(unsigned int sz)
 	_reg_htable_gc_lock = (gen_lock_t*)shm_malloc(sizeof(gen_lock_t));
 	_reg_htable_gc_lock = (gen_lock_t*)shm_malloc(sizeof(gen_lock_t));
 	if(_reg_htable_gc_lock == NULL)
 	if(_reg_htable_gc_lock == NULL)
 	{
 	{
-		LM_ERR("no more shm for lock\n");
+		SHM_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	if(lock_init(_reg_htable_gc_lock)==0)
 	if(lock_init(_reg_htable_gc_lock)==0)
@@ -202,7 +202,7 @@ int uac_reg_init_ht(unsigned int sz)
 	_reg_htable_gc = (reg_ht_t*)shm_malloc(sizeof(reg_ht_t));
 	_reg_htable_gc = (reg_ht_t*)shm_malloc(sizeof(reg_ht_t));
 	if(_reg_htable_gc==NULL)
 	if(_reg_htable_gc==NULL)
 	{
 	{
-		LM_ERR("no more shm\n");
+		SHM_MEM_ERROR;
 		lock_destroy(_reg_htable_gc_lock);
 		lock_destroy(_reg_htable_gc_lock);
 		shm_free((void*)_reg_htable_gc_lock);
 		shm_free((void*)_reg_htable_gc_lock);
 		return -1;
 		return -1;
@@ -214,7 +214,7 @@ int uac_reg_init_ht(unsigned int sz)
 		(reg_entry_t*)shm_malloc(_reg_htable_gc->htsize*sizeof(reg_entry_t));
 		(reg_entry_t*)shm_malloc(_reg_htable_gc->htsize*sizeof(reg_entry_t));
 	if(_reg_htable_gc->entries==NULL)
 	if(_reg_htable_gc->entries==NULL)
 	{
 	{
-		LM_ERR("no more shm.\n");
+		SHM_MEM_ERROR;
 		shm_free(_reg_htable_gc);
 		shm_free(_reg_htable_gc);
 		lock_destroy(_reg_htable_gc_lock);
 		lock_destroy(_reg_htable_gc_lock);
 		shm_free((void*)_reg_htable_gc_lock);
 		shm_free((void*)_reg_htable_gc_lock);
@@ -226,7 +226,7 @@ int uac_reg_init_ht(unsigned int sz)
 	_reg_htable = (reg_ht_t*)shm_malloc(sizeof(reg_ht_t));
 	_reg_htable = (reg_ht_t*)shm_malloc(sizeof(reg_ht_t));
 	if(_reg_htable==NULL)
 	if(_reg_htable==NULL)
 	{
 	{
-		LM_ERR("no more shm\n");
+		SHM_MEM_ERROR;
 		shm_free(_reg_htable_gc->entries);
 		shm_free(_reg_htable_gc->entries);
 		shm_free(_reg_htable_gc);
 		shm_free(_reg_htable_gc);
 		lock_destroy(_reg_htable_gc_lock);
 		lock_destroy(_reg_htable_gc_lock);
@@ -240,7 +240,7 @@ int uac_reg_init_ht(unsigned int sz)
 		(reg_entry_t*)shm_malloc(_reg_htable->htsize*sizeof(reg_entry_t));
 		(reg_entry_t*)shm_malloc(_reg_htable->htsize*sizeof(reg_entry_t));
 	if(_reg_htable->entries==NULL)
 	if(_reg_htable->entries==NULL)
 	{
 	{
-		LM_ERR("no more shm.\n");
+		SHM_MEM_ERROR;
 		shm_free(_reg_htable_gc->entries);
 		shm_free(_reg_htable_gc->entries);
 		shm_free(_reg_htable_gc);
 		shm_free(_reg_htable_gc);
 		shm_free(_reg_htable);
 		shm_free(_reg_htable);
@@ -452,7 +452,7 @@ int reg_ht_add_byuuid(reg_uac_t *reg)
 	ri = (reg_item_t*)shm_malloc(sizeof(reg_item_t));
 	ri = (reg_item_t*)shm_malloc(sizeof(reg_item_t));
 	if(ri==NULL)
 	if(ri==NULL)
 	{
 	{
-		LM_ERR("no more shm\n");
+		SHM_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	memset(ri, 0, sizeof(reg_item_t));
 	memset(ri, 0, sizeof(reg_item_t));
@@ -483,7 +483,7 @@ int reg_ht_add_byuser(reg_uac_t *reg)
 	ri = (reg_item_t*)shm_malloc(sizeof(reg_item_t));
 	ri = (reg_item_t*)shm_malloc(sizeof(reg_item_t));
 	if(ri==NULL)
 	if(ri==NULL)
 	{
 	{
-		LM_ERR("no more shm\n");
+		SHM_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	memset(ri, 0, sizeof(reg_item_t));
 	memset(ri, 0, sizeof(reg_item_t));
@@ -537,7 +537,7 @@ int reg_ht_add(reg_uac_t *reg)
 	nr = (reg_uac_t*)shm_malloc(sizeof(reg_uac_t) + len);
 	nr = (reg_uac_t*)shm_malloc(sizeof(reg_uac_t) + len);
 	if(nr==NULL)
 	if(nr==NULL)
 	{
 	{
-		LM_ERR("no more shm\n");
+		SHM_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	memset(nr, 0, sizeof(reg_uac_t) + len);
 	memset(nr, 0, sizeof(reg_uac_t) + len);
@@ -1096,7 +1096,7 @@ int uac_reg_update(reg_uac_t *reg, time_t tn)
 	uuid = (char*)shm_malloc(reg->l_uuid.len+1);
 	uuid = (char*)shm_malloc(reg->l_uuid.len+1);
 	if(uuid==NULL)
 	if(uuid==NULL)
 	{
 	{
-		LM_ERR("no more shm\n");
+		SHM_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	reg->timer_expires = tn;
 	reg->timer_expires = tn;

+ 1 - 1
src/modules/uac/uac_send.c

@@ -105,7 +105,7 @@ uac_send_info_t *uac_send_info_clone(uac_send_info_t *ur)
 	tp = (uac_send_info_t*)shm_malloc(sizeof(uac_send_info_t));
 	tp = (uac_send_info_t*)shm_malloc(sizeof(uac_send_info_t));
 	if(tp==NULL)
 	if(tp==NULL)
 	{
 	{
-		LM_ERR("no more shm memory\n");
+		SHM_MEM_ERROR;
 		return NULL;
 		return NULL;
 	}
 	}
 	uac_send_info_copy(ur, tp);
 	uac_send_info_copy(ur, tp);