Hello and sorry for the delayed answer!
@ Mukund
---------------------------
Unfortunately, I cannot find the "No Threads When init_snmp('progname')"
restriction. I have read it somewhere, but I cannot find it again...
Also, when running multiple threads with one session per thread (with
init_snmp('progname') or init_snmp('unique_thread_id')) the SegFault
gives no information. When Segfaults, no messages are being printed out.
By debugging each thread (using gdb) I saw that the "snmp_api.c"
explodes when the threads change. Again, no messages, no useful "info
locals", no information. Just a vast SegFault explosion at the
snmp_api.c at the time that one thread passes the operation to another.
So, as far as the messages are concerned, I cannot be of help...
@Sandvige
---------------------------
The asynchronous API would not help me at this project. Although, you
gave me the idea that did not cross my mind while searching for a
solution to my problem. So, instead of developing layers around the
multiple threads, I just locked the sessions using a mutex.
So, here is the solution I found feasible, easy and working:
------------------------------------------------------------------------------------------------------------
Only once and only in the main() function, the init_snmp() is called,
with the argv[0] name of my Program.
Each get and set request is implemented in district functions (for
example "getInteger()" or "setString()")
A Global Mutex has been added.
At the beginning of each function, an snmp session is created and opened.
When a session is being opened, the Mutex is locked.
When the session is closing, the Mutex unlocks.
Each thread uses the functions to get/set values on the MIB.
Thus, only one thread can have an active SNMP Session at a time, and no
further code, layers, APIs etc are needed.
I have been testing my Daemon since this Friday with 8 threads running
concurrently at a 24/7 mode and no SegFaults have been seen since then
(4 days and counting...)
So, I have no idea if I did the right thing or if there was a better way
which would actually work with concurrent sessions, but thanks everyone
for their help and tips!
Feel free to take a look at the whole project and the multithreaded SNMP
calls in here:
http://www.medianetlab.gr/opensource/
(Click Download, get the zip and go to the "MonitorDaemon" folder.
The files you will need are the main.c and the SNMPFunctions.c
Feel free to do anything you want with them or any other file of the
zip. Copy them, use them, print them in hardcopies and burn them in
fire.. Anything)
Again, thanx everyone very very much!
--
*/Katia Sarsempagieva/*
/ Research Assistant
Media Network Laboratory
Institute of Information and Telecommunications
NCSR Demokritos
/
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders