Hi Katia S:
I have been using multiple threads where each thread starts a client and
maintains a single session. I am using this for Informs as opposed to the
get/set.
In all the usage documentation it was found that we need to perform
init_snmp("PROGNAME"), once for all threads. Each thread creates a
session using the single session APIs. I would also like to know if the
init_snmp needs to be done per session as stated by you below. If
init_snmp is done once per process and snmp_sess_open is used to create a
valid snmp session within each thread context then multiple threads
maintaining one session per thread works as expected.
Thanks
Mukund
On Fri, Sep 7, 2012 at 5:15 AM, Katia Sarsempagieva <
kat...@iit.demokritos.gr> wrote:
> **
> Greetings everyone!
> I have already and extensively searched answers for the particular
> problem,
> but I failed to find any. So, if this topic has already been answered, I
> apologize.
>
> Problem Context:
> ---------------------------------
> Let's say I have a MIB that contains a table.
> And I have written a multi-threaded Net-SNMP Client application that reads
> and writes
> to the mentioned MIB.
> Each thread writes on its own Index. For example, only one thread will
> write and read the
> row with Index = 1 (myTable.1), so I do not have to lock any rows or
> tables to add thread protection.
> (The second thread will work on Index = 2 (myTable.2), and so on and so
> forth).
>
> Each thread creates its own SNMP Session. It initializes a session with
> the name "ThreadID=Index",
> where "Index" is the Index of the row the particular thread will play
> with.
> (Example: init_snmp("ThreadIndex=1"); )
> Later, it creates a Session and opens it.
> With the open Session, it uses get and set code to play with the MIB and
> at the end it closes the Session.
>
>
> Problem Question:
> ---------------------------------
> Are the mentioned assumptions even correct?
> Is it possible to have a multi-threaded Net-SNMP Client with one session
> per thread?
> If yes, what are the rules that have to be followed in order to avoid
> SegFaults, that are occurring at my program
> at random times (usually when the client changes to another thread or when
> a thread gets a "NULL" response via
> a snmp_synch_response function)?
>
> Environment:
> ---------------------------------
> Just in case, I post the environment parameters in which I am working.
>
> OS: Debian, Linux
> Net-SNMP Version: 5.7.1 (source code installation)
> Threading Lib: pthread.h
> Net-SNMP Client and Server, both on Localhost
> Programming Language: C
>
> Any insight on the aforementioned problem and any useful advice will be
> greatly appreciated!
> Thank you very much in advance!
>
> Best regards,
>
> --
> *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
>
>
------------------------------------------------------------------------------
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