Template:FAQ:General 17

From Net-SNMP Wiki
Revision as of 09:17, 16 August 2006 by Dts12 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Strictly speaking, no. However, it should be possible to use the library in a thread-safe manner. This is covered in detail in the file README.thread (shipped with the standard distribution), but can be summarised as follows:

  • Call 'snmp_sess_init()' prior to activating any threads.
    This reads in and parses MIB information (which isn't thread-safe) as well as preparing a session structure for subsequent use.
  • Open an SNMP session using 'snmp_sess_open()' which returns an opaque session handle, which is essentially independent of any other sessions (regardless of thread).
  • Resource locking is not handled within the library, and is the responsibility of the main application.

The applications and the agent have not been designed for threaded use. It should be safe to use the agent library to embed a subagent within a threaded application as long as *all* SNMP-related activity (including generating traps, and parsing MIBs) is handled within a single thread.

Unfortunately, the SNMPv3 support was added about the same time as the thread support and since they occurred in parallel the SNMPv3 support was never checked for multi-threading correctness. It is most likely that it is not thread-safe at this time.