Example of configuring trap recipients?

Jeff Stewart jstewart____remarq.com
Thu Feb 10 00:14:19 CET 2000


Frank,
    Please find attached a diff to fix a few memory leaks in agent++3.3.

    I've found a few others that I'm not sure how best to fix.  Specifically, the objects
in the vcp structure of the vacm are still in use at shutdown time.  I'd like to clean
them up, but I'm not sure that it's possible to do so easily.  Some of them have been
placed into the mib, and there doesn't appear to be a simple way to get them back out.
This isn't a really big deal, though.  I just prefer to keep things so that they purify
cleanly.

    Jeff

Index: notification_originator.cpp
===================================================================
RCS file: /dvlp/cvs/agent++/src/notification_originator.cpp,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 notification_originator.cpp
*** notification_originator.cpp 2000/01/21 18:16:57     1.1.1.1
--- notification_originator.cpp 2000/02/09 22:06:42
***************
*** 225,232 ****
--- 225,234 ----
                    contains(tagstr)) {
                        // determine notification type
                        typeCur.get()->get_nth(1)->get_value(notify);
+                       delete [] tagstr; tagstr = NULL;
                        break;
                }
+               delete [] tagstr; tagstr = NULL;
          }
          if (notify == NO_TRAP) {
                LOG_BEGIN(DEBUG_LOG | 6);
***************
*** 373,379 ****
            LOG(size);
            LOG(securityName.get_printable());
            LOG_END;
!         }
        }

        typeList->clearAll();
--- 375,382 ----
            LOG(size);
            LOG(securityName.get_printable());
            LOG_END;
!         }
!         delete target; target = NULL;
        }

        typeList->clearAll();
Index: snmp_request.cpp
===================================================================
RCS file: /dvlp/cvs/agent++/src/snmp_request.cpp,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 snmp_request.cpp
*** snmp_request.cpp    2000/01/21 18:16:57     1.1.1.1
--- snmp_request.cpp    2000/02/09 22:06:42
***************
*** 262,268 ****
        int status;
        u_short out_port;

!       Snmpx* snmp;
        for (out_port = OUTPORT_MAX; out_port>=OUTPORT_MIN;out_port--) {

                snmp = new Snmpx( status, out_port);
--- 262,268 ----
        int status;
        u_short out_port;

!       Snmpx* snmp = NULL;
        for (out_port = OUTPORT_MAX; out_port>=OUTPORT_MIN;out_port--) {

                snmp = new Snmpx( status, out_port);
***************
*** 275,280 ****
--- 275,281 ----
                        delete snmp;
                        continue;
                }
+               // the rest of this is unreachable. XXXJBS
                if ((status != SNMP_CLASS_SUCCESS) &&
                    (status != SNMP_CLASS_TL_IN_USE)){
                        delete snmp;
***************
*** 287,293 ****
                }
        }

!       if (out_port<OUTPORT_MIN) return SNMP_CLASS_ERROR;

        Pdux pdu;
        // the request id is set by Snmpx
--- 288,297 ----
                }
        }

!       if (out_port<OUTPORT_MIN) {
!         delete snmp; snmp = NULL; // probably unnecessary.
!         return SNMP_CLASS_ERROR;
!       }

        Pdux pdu;
        // the request id is set by Snmpx
***************
*** 304,310 ****
                status = snmp->trap(pdu, target);

        if (status == SNMP_CLASS_SUCCESS) MibIIsnmpCounters::incOutPkts();
!       delete snmp;

        return status;
  }
--- 308,314 ----
                status = snmp->trap(pdu, target);

        if (status == SNMP_CLASS_SUCCESS) MibIIsnmpCounters::incOutPkts();
!       delete snmp; snmp = NULL;

        return status;
  }
Index: snmp_textual_conventions.cpp
===================================================================
RCS file: /dvlp/cvs/agent++/src/snmp_textual_conventions.cpp,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 snmp_textual_conventions.cpp
*** snmp_textual_conventions.cpp        2000/01/21 18:16:57     1.1.1.1
--- snmp_textual_conventions.cpp        2000/02/09 22:06:42
***************
*** 418,427 ****

          if (((start == l) || (SnmpTagValue::is_delimiter(*(start-1)))) &&
              ((l+strlen(l)-start == (int)strlen(tag)) ||
!              (SnmpTagValue::is_delimiter(*(start+strlen(tag))))))
                return TRUE;
          start++;
        }
        return FALSE;
  }

--- 418,430 ----

          if (((start == l) || (SnmpTagValue::is_delimiter(*(start-1)))) &&
              ((l+strlen(l)-start == (int)strlen(tag)) ||
!              (SnmpTagValue::is_delimiter(*(start+strlen(tag)))))) {
!               delete [] l; l = NULL;
                return TRUE;
+         }
          start++;
        }
+       delete [] l; l = NULL;
        return FALSE;
  }

Index: vacm.cpp
===================================================================
RCS file: /dvlp/cvs/agent++/src/vacm.cpp,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 vacm.cpp
*** vacm.cpp    2000/01/21 18:16:57     1.1.1.1
--- vacm.cpp    2000/02/09 22:06:42
***************
*** 1176,1182 ****

  Vacm::~Vacm(void)
  {
!
  }

  boolean Vacm::addNewContext(const OctetStr &newContext)
--- 1176,1183 ----

  Vacm::~Vacm(void)
  {
!   // contents of vcp are leaked.  Some are handed to the mib.  This
!   // is going to be a bit of a pain to shut down cleanly
  }

  boolean Vacm::addNewContext(const OctetStr &newContext)





More information about the AGENTPP mailing list