get_request called twice

Guy.HINDELL____opentrade.co.uk Guy.HINDELL____opentrade.co.uk
Wed Nov 8 17:19:06 CET 2000


Hi

I've recently implemented a leaf derived from MibLeaf which overrides the
get_value() method with some code which performs rather more processing than
the simple return of a varbind. I noticed whilst debugging this code that it
was being invoked twice for each get request I sent to the agent, which is
an overhead I don't want.

The reason for this is that the MibTable::get_request() method uses the
MibTable::find() method to locate the right leaf and then calls the
get_value() method of that leaf. The resulting varbind is tested using its
valid() method, before the request is serviced using a call to the leaf's
get_request() method. This call itself calls the the get_value() method!

I fiddled with altering the code in MibTable::get_request to avoid this
second call by using the varbind produced by the first get_value() call to
complete the request as follows...

void MibTable::get_request(Request *req, int ind)
{
   ...
	Vbx leaf_val(o->get_value());

	if (leaf_val.valid()) {
		// call get request-method of
		// the MibLeaf Object
		// o->get_request(req, ind);   // Don't do this
		// response has been sent by the above call,
		// so we could leave here
		// return;				// Don't return here

		// Just do what MibLeaf->GetRequest was doing.
		if (o->get_access() >= READONLY) {
			Mib::instance->done(req->get_transaction_id(), ind,
				leaf_val);
		}
		else {
			Mib::instance->done(req->get_transaction_id(), ind,
				SNMP_ERROR_NO_ACCESS);
		}
		return;
	else {
	...


One problem with this is that get_request can't be overridden in derived
leaf classes (I don't do this anyway), but maybe another approach is an
additional get_reqest method which can take a varbind as an argument rather
than call get_value.


Guy Hindell
OpenTrade Technologies Ltd.
(guy.hindell at opentrade.co.uk)

	


* ------------------------------------------------------------------------ *
 Privileged/Confidential Information may be contained in this 
 message. If you are not the addressee indicated in this      
 message (or responsible for delivery of the message to such  
 person), you may not copy or deliver this message to anyone. 
 In such case, you should destroy this message and kindly     
 notify the sender by reply e-mail. Please advise immediately 
 if you or your employer does not consent to Internet e-mail  
 for messages of this kind. Opinions, conclusions and other   
 information in this message that do not relate to the        
 official business of my Company shall be understood as       
 neither given or endorsed by it.                             
* ------------------------------------------------------------------------ *





More information about the AGENTPP mailing list