Hi, Thanks to all,

I'm also using Redhat9, pthread an mutex locking, anyway..
I create single session in thread for sending traps (not in main thread whrere sub agent is running). I'm using "Single session API" functions: snmp_sess_open(), snmp_sess_send() and snmp_sess_close() to manage session and snmp_pdu_create() to create pdu. I couldn't find function to create pdu for "Single API use", so I asumed that snmp_pdu_create() function is "thread safe"!?  Is there any other way to create pdu, than showed bellow?
So, function for send trap looks like:

snmp_sess_open()
...

/** the way I create PDU:  Is that OK? **/
pPdu = (struct snmp_pdu*) snmp_pdu_create(SNMP_MSG_TRAP);
pPdu->sessid = pSession->sessid;   
pPdu->trap_type = 6;
pPdu->specific_type = 1;
pPdu->time = netsnmp_get_agent_uptime();
/**/

...
snmp_sess_send()
...

if (pPdu != NULL)
    snmp_free_pdu(pPdu);     //Here is the problem (segmentation fault)! (if I comment this line, works fine!)





Gary Clark wrote:
Yes,

I have sent traps in using a pthread. No problem. Are you trying to free a
PDU that has not been malloc?
Segmentation faults are usual candidates (using the the political term) for
bad memory accesses.
So your pointer may be invalid? Can you dump out what you allocate and what
you free? Again adding trace
is essential.

Much appreciated,
Garyc
----- Original Message -----
From: "Vili Germic" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 27, 2004 6:08 AM
Subject: Sending traps in another thread


  
Hi all,

I'm writting NET-Snmp sub agent.
Has anybody tried to send traps in other thread that in main thread of
sub agent?
I'm having problems when snmp_free_pdu() is called. (segmentation fault).
Any ideas on this? Has anybody do something like this?

Best regards,
Vili


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Net-snmp-users mailing list
[EMAIL PROTECTED]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
    


  

Reply via email to