[sr-dev] git:master: core: use PV api buffers for mod fixup

Daniel-Constantin Mierla miconda at gmail.com
Fri Jul 15 22:56:01 CEST 2011


Module: sip-router
Branch: master
Commit: 2f29210763f7587c5e3bb7df2bc2c4f36be727f1
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2f29210763f7587c5e3bb7df2bc2c4f36be727f1

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri Jul 15 16:42:21 2011 +0200

core: use PV api buffers for mod fixup

- functions to get the values from mod fixup structures use now the
  buffers from PV api

---

 pvapi.c     |    6 +++---
 sr_module.c |   10 +++-------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/pvapi.c b/pvapi.c
index 8f87d58..8577bf1 100644
--- a/pvapi.c
+++ b/pvapi.c
@@ -1608,6 +1608,7 @@ static int _pv_print_buffer_size  = PV_DEFAULT_PRINT_BUFFER_SIZE;
 /* 6 mod params + 4 direct usage from mods */
 #define PV_DEFAULT_PRINT_BUFFER_SLOTS 10
 static int _pv_print_buffer_slots = PV_DEFAULT_PRINT_BUFFER_SLOTS;
+static int _pv_print_buffer_index = 0;
 
 /**
  *
@@ -1677,10 +1678,9 @@ int pv_reinit_buffer(void)
 char* pv_get_buffer(void)
 {
 	char *p;
-	static int _pv_print_buffer_itr = 0;
 
-	p = _pv_print_buffer[_pv_print_buffer_itr];
-	_pv_print_buffer_itr = (_pv_print_buffer_itr+1)%_pv_print_buffer_slots;
+	p = _pv_print_buffer[_pv_print_buffer_index];
+	_pv_print_buffer_index = (_pv_print_buffer_index+1)%_pv_print_buffer_slots;
 
 	return p;
 }
diff --git a/sr_module.c b/sr_module.c
index 3fc0788..c77b761 100644
--- a/sr_module.c
+++ b/sr_module.c
@@ -57,6 +57,7 @@
 #include "route_struct.h"
 #include "flags.h"
 #include "trim.h"
+#include "pvapi.h"
 #include "globals.h"
 #include "rpc_lookup.h"
 #include "sr_compat.h"
@@ -1501,8 +1502,6 @@ int fixup_str_2(void** param, int param_no)
 
 
 
-#define PV_PRINT_BUF_SIZE  1024
-#define PV_PRINT_BUF_NO    6
 /** Get the function parameter value as string.
  *  @return  0 - Success
  *          -1 - Cannot get value
@@ -1513,8 +1512,6 @@ int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param)
 	int ret;
 	avp_t* avp;
 	pv_value_t pv_val;
-	static int buf_itr = 0; /* ugly hack needed for PVE */
-	static char pve_buf[PV_PRINT_BUF_NO][PV_PRINT_BUF_SIZE];
 	
 	switch(param->type) {
 		case FPARAM_REGEX:
@@ -1559,9 +1556,8 @@ int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param)
 			}
 			break;
 		case FPARAM_PVE:
-			dst->s=pve_buf[buf_itr];
-			dst->len=PV_PRINT_BUF_SIZE;
-			buf_itr = (buf_itr+1)%PV_PRINT_BUF_NO;
+			dst->s=pv_get_buffer();
+			dst->len=pv_get_buffer_size();
 			if (unlikely(pv_printf(msg, param->v.pve, dst->s, &dst->len)!=0)){
 				ERR("Could not convert the PV-formated string to str\n");
 				dst->len=0;




More information about the sr-dev mailing list