No subject


Sun Mar 11 03:57:02 CET 2012


event code...

> It seems from my review of the code so far that each thread I have is
>  sometimes calling the GetEvents and HandleEvents calls, but then 
> these are locking a global msgqueue and matching up the unique 
> request id's to place the responses with the appropriate requests 
> even if those requests were made by a different thread then the one 
> that has triggered the HandleEvents.  Is this accurate?

Beside of the word global msgqueue, this is right. Each Snmp object has
its own EventListHolder which has its own msg and notification queues.
So the lock is per Snmp object. If two threads use the same Snmp object
it is possible that one thread triggers the recvfrom of the other
thread, but the response is stored in the msg queue and the other thread
will only get it from there.

> If so for my purposes it seems like I'm wasting alot of cycles and 
> getting into some threading issues because of each thread trying to 
> check for new data and doing recvfroms the contending for the global 
> queue.  Wouldn't it be better in a multithreaded scenario to have a 
> single event handler thread that was dedicated to checking the 
> sockets, getting data, and updating the global queue, then just have 
> each thread wait for a response (or error indication) to appear in 
> that queue?

Well, long ago the EventListHOlder class was created to remove the
global singleton event queue. This allows processing of async callbacks
and notifications for multiple threads.

>  And if that makes sense then is there anyway to get this
>  type of setup in SNMP++ or would it require me to make some fairly 
> major modications to the IO hanlding architecture of the library.  I 

It's not that easy as to allow multipmle v3MP objects, but as there once
was a global queue, it can be done. The latest snapshot removes the X11
and user defined queues from the event code, so  it will be easier to
search through the code.

But before you start digging into the code, some questions, so may be I
can find out what's going wrong.

Are you using sync or async requests?
Do you use the same Snmp object within different threads at the same time?
Do you get timeouts although the agent sends a reply?

Regards,
  Jochen



More information about the AGENTPP mailing list