lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] memory leak when sending snmp trap


From: address@hidden
Subject: Re: [lwip-users] memory leak when sending snmp trap
Date: Thu, 11 Jun 2009 10:08:24 +0200
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)

Unfortunately, I also don't have that much experience with the snmp code, and I did not use traps so far (only snmpwalk). But what I can say about your code is that it is likely to fail because you are using the snmp functions from an application thread.

At least snmp_send_trap will call the UDP raw API eventually (udp_sendto or something like that), which *must not* be called from any other thread than lwIP's tcpip_thread or you will run into problems. You should correct that and then report if you are still having memory leaks.

Simon

Alexandre Malo wrote:
Hello,
I am having memory leak with a task sending trap. Here is my simple task: #define MY_SNMP_ENTERPRISE_ID 4464
#define MY_SNMP_SYSOBJID_LEN 7
#define MY_SNMP_SYSOBJID {1, 3, 6, 1, 4, 1, MY_SNMP_ENTERPRISE_ID}
void vSendTrapTask( void * pvParameters )
{
   portTickType xLastWakeTime;
   struct snmp_obj_id objid = {MY_SNMP_SYSOBJID_LEN, MY_SNMP_SYSOBJID};
   struct snmp_varbind *vb;
static unsigned char msg[] = "address@hidden <mailto:address@hidden>";
   static unsigned char msglen= 22;
(void) pvParameters; for ( ;; )
   {
      xLastWakeTime = xTaskGetTickCount();
vb = snmp_varbind_alloc(&objid,
                           SNMP_ASN1_OPAQUE,
                           msglen);
vb->value = &msg; trap_msg.outvb.head = vb;
      trap_msg.outvb.tail = vb;
      trap_msg.outvb.count = 1;
snmp_send_trap(SNMP_GENTRAP_ENTERPRISESPC, &objid, 0); trap_msg.outvb.head = NULL;
      trap_msg.outvb.tail = NULL;
      trap_msg.outvb.count = 0;
      vb->value = NULL;
snmp_varbind_free(vb); // Wait for the next cycle.
      vTaskDelayUntil( &xLastWakeTime, 10 );
   }
}
Do I use correctly snmp_varbind_alloc? I want to notify that the thread works for a random number of sent trap. I tried it more than once and its never the same amount of trap that is received. Thanks!
Alexandre Malo
------------------------------------------------------------------------

_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]