[AGENT++] Is snmp++ and agent++ an exception-safe library?

Claus Klein claus.klein at arcormail.de
Mon Dec 10 22:33:55 CET 2018


> Am 10.12.2018 um 21:42 schrieb Jochen Katz <katz at agentpp.com>:
> 
> In this case your exception handler has to restart your application
> without trying to clean up snmp++/agent++.
with code like this, then we have big resource leek:

class AGENTPP_DECL snmp_community_mib : public MibGroup {
public:
    snmp_community_mib();
    virtual ~snmp_community_mib() {}
    static void add_public();
};


snmp_community_mib::snmp_community_mib()
    : MibGroup("1.3.6.1.6.3.18.1", "snmpCommunityMIB")
{
    add(new snmpCommunityEntry());
    add(new snmpTargetAddrExtEntry());
}


Do you think, this mutex would be unlocked after an exception:

UdpAddress* snmpTargetAddrTMask::getUdpAddress()
{
    snmpTargetAddrEntry::instance->start_synch();
    MibTableRow* r =
        snmpTargetAddrEntry::instance->find_index(my_row->get_index());
    if (!r) {
        snmpTargetAddrEntry::instance->end_synch();
        return 0;
    }
    int domain = ((snmpTargetAddrTDomain*)r->get_nth(0))->get_state();
    snmpTargetAddrEntry::instance->end_synch();
    switch (domain) {
    case 1:
    case 101:
    case 102:
        UdpAddress* address = new UdpAddress();
        *address            = (*(OctetStr*)value);
        return address;
    }
    return 0;
}

With Regards
Claus Klein


More information about the AGENTPP mailing list