From e1ebc4be355a1f3b8fe3c18fa3f2724c69927f4c Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 12 Feb 2008 07:40:34 +0000 Subject: done a bit more cleanup on the "rsyslog way of doing things" --- plugins/omsnmp/omsnmp.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/plugins/omsnmp/omsnmp.c b/plugins/omsnmp/omsnmp.c index f7777523..72a40d1c 100644 --- a/plugins/omsnmp/omsnmp.c +++ b/plugins/omsnmp/omsnmp.c @@ -142,13 +142,12 @@ static rsRetVal omsnmp_exitSession(instanceData *pData) static rsRetVal omsnmp_initSession(instanceData *pData) { DEFiRet; + netsnmp_session session; /* should not happen, but if session is not cleared yet - we do it now! */ if (pData->snmpsession != NULL) omsnmp_exitSession(pData); - netsnmp_session session; - dbgprintf( "omsnmp_initSession: ENTER - Target = '%s' on Port = '%d'\n", pData->szTarget, pData->iPort); putenv(strdup("POSIXLY_CORRECT=1")); @@ -167,17 +166,11 @@ static rsRetVal omsnmp_initSession(instanceData *pData) } pData->snmpsession = snmp_open(&session); - if (pData->snmpsession == NULL) - { + if (pData->snmpsession == NULL) { logerrorVar("omsnmp_initSession: snmp_open to host '%s' on Port '%d' failed\n", pData->szTarget, pData->iPort); - /* Stay suspended */ + /* Stay suspended */ iRet = RS_RET_SUSPENDED; } - else - { - /* Report success */ - iRet = RS_RET_OK; - } RETiRet; } @@ -196,16 +189,12 @@ static rsRetVal omsnmp_sendsnmp(instanceData *pData, uchar *psz) const char *strErr = NULL; /* Init SNMP Session if necessary */ - if (pData->snmpsession == NULL) - { - iRet = omsnmp_initSession(pData); - if (iRet != RS_RET_OK) { - ABORT_FINALIZE(iRet); /* This will most likely return RS_RET_SUSPENDED */ - } + if (pData->snmpsession == NULL) { + CHKiRet(omsnmp_initSession(pData)); } /* String should not be NULL */ - assert(psz != NULL); + ASSERT(psz != NULL); dbgprintf( "omsnmp_sendsnmp: ENTER - Syslogmessage = '%s'\n", (char*)psz); /* If SNMP Version1 is configured !*/ @@ -305,6 +294,7 @@ finalize_it: RETiRet; } + BEGINtryResume CODESTARTtryResume iRet = omsnmp_initSession(pData); -- cgit