snmpstats Improve formatting, add comments on InterProcessBuffer growing forever
authorOlle E. Johansson <oej@edvina.net>
Tue, 24 May 2016 13:13:44 +0000 (15:13 +0200)
committerOlle E. Johansson <oej@edvina.net>
Tue, 24 May 2016 13:18:24 +0000 (15:18 +0200)
modules/snmpstats/interprocess_buffer.c
modules/snmpstats/snmpObjects.c
modules/snmpstats/snmpSIPContactTable.c

index 3f00978..8edc0ea 100644 (file)
@@ -85,11 +85,11 @@ int initInterprocessBuffers(void)
        frontRegUserTableBuffer =  shm_malloc(sizeof(interprocessBuffer_t));
        endRegUserTableBuffer   =  shm_malloc(sizeof(interprocessBuffer_t));
 
-    if(frontRegUserTableBuffer == NULL || endRegUserTableBuffer == NULL)
-    {
-        LM_ERR("no more shared memory\n");
-        return -1;
-    }
+       if(frontRegUserTableBuffer == NULL || endRegUserTableBuffer == NULL)
+       {
+               LM_ERR("no more shared memory\n");
+               return -1;
+       }
 
        memset(frontRegUserTableBuffer, 0x00, sizeof(interprocessBuffer_t));
        memset(endRegUserTableBuffer,   0x00, sizeof(interprocessBuffer_t));
@@ -101,27 +101,27 @@ int initInterprocessBuffers(void)
        interprocessCBLock = lock_alloc();
        if(interprocessCBLock==NULL)
        {
-        LM_ERR("cannot allocate the lock\n");
-        shm_free(frontRegUserTableBuffer);
-        frontRegUserTableBuffer = NULL;
-        shm_free(endRegUserTableBuffer);
-        endRegUserTableBuffer = NULL;
-        return -1;
+               LM_ERR("cannot allocate the lock\n");
+               shm_free(frontRegUserTableBuffer);
+               frontRegUserTableBuffer = NULL;
+               shm_free(endRegUserTableBuffer);
+               endRegUserTableBuffer = NULL;
+               return -1;
        }
        lock_init(interprocessCBLock);
 
        hashTable = createHashTable(HASH_SIZE);
-    if(hashTable == NULL)
-    {
-        LM_ERR("no more shared memory\n");
+       if(hashTable == NULL)
+       {
+               LM_ERR("no more shared memory\n");
                lock_destroy(interprocessCBLock);
                lock_dealloc(interprocessCBLock);
-        shm_free(frontRegUserTableBuffer);
-        frontRegUserTableBuffer = NULL;
-        shm_free(endRegUserTableBuffer);
-        endRegUserTableBuffer = NULL;
-        return -1;
-    }
+               shm_free(frontRegUserTableBuffer);
+               frontRegUserTableBuffer = NULL;
+               shm_free(endRegUserTableBuffer);
+               endRegUserTableBuffer = NULL;
+               return -1;
+       }
 
        return 1;
 }
@@ -178,7 +178,7 @@ void handleContactCallbacks(ucontact_t *contactInfo, int type, void *param)
 
        /* This is the first element to be added. */
        if (frontRegUserTableBuffer->next == NULL) {
-               frontRegUserTableBuffer->next     = currentBufferElement;
+               frontRegUserTableBuffer->next = currentBufferElement;
        } else {
                endRegUserTableBuffer->next->next = currentBufferElement;
        }
@@ -356,12 +356,12 @@ static void executeInterprocessBufferCmd(interprocessBuffer_t *currentBuffer)
 
 void freeInterprocessBuffer(void)
 {
-    interprocessBuffer_t *currentBuffer, *previousBuffer;
+       interprocessBuffer_t *currentBuffer, *previousBuffer;
 
        if (frontRegUserTableBuffer==NULL
                        || frontRegUserTableBuffer->next == NULL
                        || endRegUserTableBuffer==NULL) {
-        LM_DBG("Nothing to clean\n");
+               LM_DBG("Nothing to clean\n");
                return;
        }
 
@@ -373,18 +373,18 @@ void freeInterprocessBuffer(void)
 
        while (currentBuffer != NULL) {
 
-        previousBuffer = currentBuffer;
-        currentBuffer = currentBuffer->next;
-        shm_free(previousBuffer->stringName);
-        shm_free(previousBuffer->stringContact);
-        shm_free(previousBuffer);
+               previousBuffer = currentBuffer;
+               currentBuffer = currentBuffer->next;
+               shm_free(previousBuffer->stringName);
+               shm_free(previousBuffer->stringContact);
+               shm_free(previousBuffer);
 
        }
 
-    if(frontRegUserTableBuffer)
-        shm_free(frontRegUserTableBuffer);
+       if(frontRegUserTableBuffer)
+               shm_free(frontRegUserTableBuffer);
 
-    if(endRegUserTableBuffer)
-        shm_free(endRegUserTableBuffer);
+       if(endRegUserTableBuffer)
+               shm_free(endRegUserTableBuffer);
 
 }
index 6223609..b5d87c4 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
  * USA
  *
- * History:
- * --------
- * 2006-11-23 initial version (jmagder)
- * 2007-02-16 Moved all OID registrations from the experimental branch to 
- *            Kamailio's IANA assigned enterprise branch. (jmagder)
- * 
  * Note: this file originally auto-generated by mib2c using
  *             : mib2c.scalar.conf,v 1.9 2005/01/07 09:37:18 dts12 Exp $
  *
index d518fa1..ca6586b 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
  * USA
  *
- * History:
- * --------
- * 2006-11-23 initial version (jmagder)
- * 
  * Note: this file originally auto-generated by mib2c using
  *        mib2c.array-user.conf 
  *
  *    the interprocess buffer with consumeInterprocessBuffer().  The function
  *    will add/delete rows to the tables, and then service the SNMP request.
  *
+ * 4) If the SNMP request is not received, the InterProcessBuffer keeps growing
+ *    until end of time. This is not good. A timer callback or something else is
+ *    needed to process it.
+ *
  * Notes: 
  *
  * - The interprocess buffer was necessary, because NetSNMP's containers can be