[AGENT++] When does Agent++ check if oid is valid ?

Frank Fock fock at agentpp.com
Fri Nov 28 17:13:22 CET 2003


Hi Dirk,

Dirk Merettig wrote:

>Hi all,
>I have a question about when Agent++ checks if the OID it receives in a
>get-request is checked for validity.
>  
>
I assume that you mean by "validity" whether an instance with such an OID
exists and not whether it may be accessed.

>My problem is that I have tables that change size while the Agent runs
>depending on for example how many rings exist in my program.
>Now I want to have a central point where I can adjust the tables to the
>right sizes.
>  
>
The below code is OK for single threaded agent only (_THREADS
not #defined or by using a ThreadPool with size one). In a multi-threaded
agent, you will have to make sure, that the ThreadPool is idle or you
will have to synchronize access to the tables you want to update.
Therefore it could be better to update tables on demand, by overwriting
the MibTable::uodate method. You can find more information on this
in the mailing list archives.

>  while (!Terminated) // loop until terminated
>  {
>    // wait for incoming request max 50 sec
>    // and then just loop once
>    req = Owner->reqList->receive(50);
>    if (req)
>    {
>      AddProtLine("Request received");
>      Synchronize(ProcessRequest);
>    }
>  }
>}
>//---------------------------------------------------------------------------
>void __fastcall TSNMPListen::ProcessRequest(void)
>{
>  int ringCount = MainFrWin->RingWinList->Count;
>  int ringTableCount = hytec_nwm_mib_hytecNWMRingEntry::instance->size();
>  if (ringCount > ringTableCount)
>hytec_nwm_mib_hytecNWMRingEntry::instance->table_up();
>  if (ringCount < ringTableCount)
>hytec_nwm_mib_hytecNWMRingEntry::instance->table_down();
>  Owner->mib->process_request(req); // process the request
>}
>
>So now, I adjust the tables ( only RingCount in the example) between
>reqList->receive and mib->process_request. So far it seems to work. Does
>Agent++ check for the validity of the OID in reqList->receive or in
>process_request ? I guess its process_request ?
>  
>
Yes, the latter is true.

>Can I nevertheless expect inconsistencies with this code ?
>  
>
Yes, with _THREADS defined.

>Are there better solutions ?
>
>  
>
Yes, see above.

Best regards,
Frank





More information about the AGENTPP mailing list