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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Sat Dec 22 08:32:31 2012 +0100

core: proper pv buffer reinitialization

- reported by Olle Johansson, FS#259

---

 pvapi.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/pvapi.c b/pvapi.c
index b438362..aafc5b8 100644
--- a/pvapi.c
+++ b/pvapi.c
@@ -1854,9 +1854,11 @@ void pv_destroy_api(void)
 static char **_pv_print_buffer = NULL;
 #define PV_DEFAULT_PRINT_BUFFER_SIZE 1024
 static int _pv_print_buffer_size  = PV_DEFAULT_PRINT_BUFFER_SIZE;
+static int _pv_print_buffer_size_active  = 0;
 /* 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_slots_active = 0;
 static int _pv_print_buffer_index = 0;
 
 /**
@@ -1890,6 +1892,9 @@ int pv_init_buffer(void)
        }
        LM_DBG("PV print buffer initialized to [%d][%d]\n",
                        _pv_print_buffer_slots, _pv_print_buffer_size);
+       _pv_print_buffer_slots_active = _pv_print_buffer_slots;
+       _pv_print_buffer_size_active = _pv_print_buffer_size;
+
        return 0;
 }
 
@@ -1902,12 +1907,14 @@ void pv_destroy_buffer(void)
 
        if(_pv_print_buffer==NULL)
                return;
-       for(i=0; i<_pv_print_buffer_slots; i++)
+       for(i=0; i<_pv_print_buffer_slots_active; i++)
        {
                if(_pv_print_buffer[i]!=NULL)
                        pkg_free(_pv_print_buffer[i]);
        }
        pkg_free(_pv_print_buffer);
+       _pv_print_buffer_slots_active = 0;
+       _pv_print_buffer_size_active = 0;
        _pv_print_buffer = NULL;
 }
 
@@ -1916,8 +1923,8 @@ void pv_destroy_buffer(void)
  */
 int pv_reinit_buffer(void)
 {
-       if(_pv_print_buffer_size==PV_DEFAULT_PRINT_BUFFER_SIZE
-                       && 
_pv_print_buffer_slots==PV_DEFAULT_PRINT_BUFFER_SLOTS)
+       if(_pv_print_buffer_size==_pv_print_buffer_size_active
+                       && 
_pv_print_buffer_slots==_pv_print_buffer_slots_active)
                return 0;
        pv_destroy_buffer();
        return pv_init_buffer();


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to