Agent Modes
This is a Good Answer article. It was likely created as a response to a question on a Net-SNMP Mailing List and written up here for others to see. It likely covers material not yet in the FAQ or in the Tutorial but may someday be moved there
Contents
Question
What are the various modes that the agent goes through when answering requests.
Answer
Get processing
TBD
Set processing
SET_RESERVE1
The purpose of SET_RESERVE1 is to try and detect invalid SET requests as soon as possible. If any of the columns are assigned an impossible value (wrong type, or out-of-range, etc), then the request fails.
SET_RESERVE2
The purpose of SET_RESERVE2 is to set up/allocate the data structure for a new row or perform any resource allocation needed for further processing (e.g. database locks).
SET_FREE
The purpose of SET_FREE is to undo anything done in the two SET_RESERVE passes, if some aspect of the request proves unacceptable. This means possibly releasing the data structure for a new row, if one has just been created.
SET_ACTION
SET_ACTION assigns the appropriate column values to the data structure for this row (either the new structure created in the SET_RESERVE2 step, or an existing row structure).
SET_UNDO
SET_UNDO reverses anything done in the two SET_RESERVE steps or SET_ACTION - called if some part of the SET_ACTION processing fails. This is similar to the SET_FREE processing, but also needs to reverse any newly assigned values.
SET_COMMIT
The purpose of SET_COMMIT is to confirm that the processing of the SET request has completed successfully, and perform any "irreversible" actions.
Baby Steps
see agent/helpers/baby_steps.c
/* * Baby Steps Flow Chart (2004.06.05) * * * * +--------------+ +================+ U = unconditional path * * |optional state| ||required state|| S = path for success * * +--------------+ +================+ E = path for error * *********************************************************************** * * +--------------+ * | pre | * | request | * +--------------+ * | U * +-------------+ +==============+ * | row |f|<-------|| object || * | create |1| E || lookup || * +-------------+ +==============+ * E | | S | S * | +------------------>| * | +==============+ * | E || check || * |<---------------|| values || * | +==============+ * | | S * | +==============+ * | +<-------|| undo || * | | E || setup || * | | +==============+ * | | | S * | | +==============+ * | | || set ||-------------------------->+ * | | || value || E | * | | +==============+ | * | | | S | * | | +--------------+ | * | | | check |-------------------------->| * | | | consistency | E | * | | +--------------+ | * | | | S | * | | +==============+ +==============+ | * | | || commit ||-------->|| undo || | * | | || || E || commit || | * | | +==============+ +==============+ | * | | | S U |<--------+ * | | +--------------+ +==============+ * | | | irreversible | || undo || * | | | commit | || set || * | | +--------------+ +==============+ * | | | U U | * | +-------------->|<------------------------+ * | +==============+ * | || undo || * | || cleanup || * | +==============+ * +---------------------->| U * | * (err && f1)------------------->+ * | | * +--------------+ +--------------+ * | post |<--------| row | * | request | U | release | * +--------------+ +--------------+ * */