[AGENT++] Nice to meet you, all.

Jochen Katz katz at agentpp.com
Tue Jan 12 22:46:28 CET 2010


Hi,

you will have to create some synchronization between the get_request()
and the callback function, because if the get_request() function returns
immediately after sending the IPC request, agent++ will send the
response back to the manager. So at the time your callback is called, it
is too late.

I'm adding some notes below:

> But I still have a question, look this pseudo-code:
> class A : public MibLeaf
> {
> public:
> get_request();
> get_request_callback(Response);
> };
> 
> MibLeaf::get_request()
> {
>     /* send msg to MSTP protocol process, to get the runtime info from
>         MSTP process.
>         It just send the request, and we will get the info from MSTP by
>         get_request_callback() */
>     send_to_mstp_process(SendToMsg, get_request_callback);

Block at this point until the callback is called and get the reurned
value to store it in the MibLeaf obect.

> }
> 
> get_request_callback(Response)
> {
>      //The info from MSTP is in Response

Store the returned value somewhere the blocked thread can get it and
allow the thread to continue.

> }
> 
> Because I should get info from different process, and it is by 
> asynchronized I/O(my system is using asynchronized I/O to do
> the IPC, and I should follow this rule).
> The question is:
> When leaving MibLeaf::get_request() member function, I still
> not get the info I want, how should I resolve this question?

The above would solve it, but you have to take care that your async
communication mechanism is fast enough. Otherwise the SNMP manager will
have to increase the timeout for its requests.

Another possibility would be to do the data update periodically or
triggered from the main receive loop.

Regards,
  Jochen



More information about the AGENTPP mailing list