diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-11 11:59:50 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-11 11:59:50 +0000 |
commit | fbdee85530d817b92b5272b76fb645e1b3bf76c4 (patch) | |
tree | c1cbfb5fc0f6ec7c279acc565efcc835e46f97a8 /plugins | |
parent | f758dae5f04d2eaa333374c0c3880f4c1ffef6d5 (diff) | |
download | rsyslog-fbdee85530d817b92b5272b76fb645e1b3bf76c4.tar.gz rsyslog-fbdee85530d817b92b5272b76fb645e1b3bf76c4.tar.xz rsyslog-fbdee85530d817b92b5272b76fb645e1b3bf76c4.zip |
adapted omsnmp to the rsyslog way of handling "exceptions"
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/omsnmp/omsnmp.c | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/plugins/omsnmp/omsnmp.c b/plugins/omsnmp/omsnmp.c index 47f3ee95..6a7e18f0 100644 --- a/plugins/omsnmp/omsnmp.c +++ b/plugins/omsnmp/omsnmp.c @@ -212,11 +212,7 @@ static rsRetVal omsnmp_sendsnmp(instanceData *pData, uchar *psz) { strErr = snmp_api_errstring(snmp_errno); logerrorVar("omsnmp_sendsnmp: Adding trap OID failed '%s' with error '%s' \n", pData->szSyslogMessageOID, strErr); - - /* CLEANUP */ - snmp_free_pdu(pdu); - - return RS_RET_FALSE; + ABORT_FINALIZE(RS_RET_FALSE); } } @@ -231,11 +227,7 @@ static rsRetVal omsnmp_sendsnmp(instanceData *pData, uchar *psz) { const char *str = snmp_api_errstring(iErrCode); logerrorVar( "omsnmp_sendsnmp: Invalid SyslogMessage OID, error code '%d' - '%s'\n", iErrCode, str ); - - /* CLEANUP */ - snmp_free_pdu(pdu); - - return RS_RET_FALSE; + ABORT_FINALIZE(RS_RET_FALSE); } } else @@ -243,10 +235,7 @@ static rsRetVal omsnmp_sendsnmp(instanceData *pData, uchar *psz) strErr = snmp_api_errstring(snmp_errno); logerrorVar("omsnmp_sendsnmp: Parsing SyslogMessageOID failed '%s' with error '%s' \n", pData->szSyslogMessageOID, strErr); - /* CLEANUP */ - snmp_free_pdu(pdu); - - return RS_RET_FALSE; + ABORT_FINALIZE(RS_RET_FALSE); } /* Send the TRAP */ @@ -261,22 +250,20 @@ static rsRetVal omsnmp_sendsnmp(instanceData *pData, uchar *psz) /* Debug Output! */ logerrorVar( "omsnmp_sendsnmp: snmp_send failed error '%d', Description='%s'\n", iErrorCode*(-1), api_errors[iErrorCode*(-1)]); - - /* Important we must free the PDU! */ - snmp_free_pdu(pdu); - - /* Close SNMP Session */ - snmp_close(ss); - /* TODO! CLEANUP */ - return RS_RET_FALSE; + ABORT_FINALIZE(RS_RET_FALSE); } - else - { - /* Just Close SNMP Session */ - snmp_close(ss); + +finalize_it: + if(iRet != RS_RET_OK)= { + if(pdu != NULL) { + snmp_free_pdu(pdu); + } } + if(ss != NULL) + snmp_close(ss); + dbgprintf( "omsnmp_sendsnmp: LEAVE\n"); RETiRet; } |