[AGENT++] Threading with Agent++

Dan message.board.buffer+agentpp_mailing_list at gmail.com
Thu Nov 30 22:10:05 CET 2006


Hey All,

I wrote an agent that retrieves some of the information for its MIB
objects via a serial port.  That is, when a manager does a GET on
certain objects, the agent has to write and read from the serial port
in order to return the proper information.

Since Agent++ runs multiple threads to handle responses from managers,
I thought it would be wise to use a mutex to protect the serial port
from multiple threads attempting to use it at once.  It seems to work
fine, except when certain log levels are set.  In particular, if
EVENT_LOG > 0, INFO_LOG > 1, or DEBUG_LOG > 1 then the agent crashes
with:

20061130.15:56:16: 14052: (2)ERROR  : Synchronized mutex_destroy
failed with (result)(ptr): (16), (134686092)
20061130.15:56:16: 14052: (2)ERROR  : Synchronized mutex_destroy
failed with (result)(ptr): (16), (134688700)
Segmentation fault, aborting.

This happens just as the agent is starting - it never gets to a point
where I can begin sending GETs with my manager.  Actually, the crash
happens right as the mutex that I created to protect the serial port
is being initialized with pthread_mutex_init(mutex, NULL);

Is there anything special that should be kept in mind when using
mutex's with Agent++?  Why is this problem affected by the log levels?
 Again, if the log levels are set so that EVENT_LOG=0, INFO_LOG=1, and
DEBUG_LOG=1 then it all seems to work fine - no crashing and the
serial port is used with the mutex behaving properly.

I'd also be interested in knowing what type of issues I may need to
look out for with creating my own threads within Agent++.  For
example, I may want to create a separate thread to constantly do the
necessary work with the serial port and then have the GETs just return
the most recent data (which would have been obtained by that thread
working with the serial).

Thanks,
Dan



More information about the AGENTPP mailing list