Ver código fonte

pv: use pv cache to lookup avp name for $cnt(...)

(cherry picked from commit eb5b9c6965d1da46f8cb45d3ac2eb6598b3b6dea)
(cherry picked from commit 3d8df518f78eefd706b6c98f1dd90e739d2fec39)
Daniel-Constantin Mierla 11 anos atrás
pai
commit
e49da619c4
1 arquivos alterados com 6 adições e 15 exclusões
  1. 6 15
      modules/pv/pv_core.c

+ 6 - 15
modules/pv/pv_core.c

@@ -2641,30 +2641,21 @@ int pv_parse_cnt_name(pv_spec_p sp, str *in)
 	if(in->s==NULL || in->len<=0)
 		return -1;
 
+	pv = pv_cache_get(in);
 	pv = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
-	if(pv==NULL)
+	if(pv==NULL) {
+		LM_ERR("cannot find pv name [%.*s]\n", in->len, in->s);
 		return -1;
+	}
 
-	memset(pv, 0, sizeof(pv_spec_t));
-
-	if(pv_parse_spec(in, pv)==NULL)
-		goto error;
-
-	if(pv->type!=PVT_AVP)
-	{
+	if(pv->type!=PVT_AVP) {
 		LM_ERR("expected avp name instead of [%.*s]\n", in->len, in->s);
-		goto error;
+		return -1;
 	}
 
 	sp->pvp.pvn.u.dname = (void*)pv;
 	sp->pvp.pvn.type = PV_NAME_PVAR;
 	return 0;
-
-error:
-	LM_ERR("invalid pv name [%.*s]\n", in->len, in->s);
-	if(pv!=NULL)
-		pkg_free(pv);
-	return -1;
 }