[PATCH] SELECT1: Break out of processPendingEvents() ...
Dominik Vogt
dvogt at ffm.tc.iot.dtag.de
Mon Aug 2 13:31:15 CEST 2010
... if m_eventList.Done() is true. There was no way to break out of stopping
the loop in processPendingEvents(), so it might take a long time before
processing stops after SNMPExitMainLoop() or stop_poll_thread() is called.
---
src/eventlistholder.cpp | 16 ++++++++++++++++
src/uxsnmp.cpp | 1 +
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/eventlistholder.cpp b/src/eventlistholder.cpp
index 3185b27..0c46501 100644
--- a/src/eventlistholder.cpp
+++ b/src/eventlistholder.cpp
@@ -97,6 +97,10 @@ int EventListHolder::SNMPProcessPendingEvents()
msec now(0, 0);
int status;
+ if (m_eventList.Done())
+ {
+ return status;
+ }
pevents_mutex.lock();
if (m_is_processing_events)
{
@@ -136,6 +140,10 @@ restart_loop:
delete [] pollfds;
pollfds = 0;
}
+ if (m_eventList.Done())
+ {
+ return status;
+ }
// go through the message queue and resend any messages
// which are past the timeout.
@@ -214,6 +222,10 @@ int EventListHolder::SNMPProcessPendingEvents()
msec now(0, 0);
int status = 0;
+ if (m_eventList.Done())
+ {
+ return status;
+ }
pevents_mutex.lock();
if (m_is_processing_events)
{
@@ -243,6 +255,10 @@ restart_loop:
// TM should we do anything with bad status?
}
} while (nfound > 0 && !m_eventList.Done());
+ if (m_eventList.Done())
+ {
+ return status;
+ }
pevents_mutex.lock();
if (m_is_processing_events_restart_necessary)
{
diff --git a/src/uxsnmp.cpp b/src/uxsnmp.cpp
index e033b50..6c5c792 100644
--- a/src/uxsnmp.cpp
+++ b/src/uxsnmp.cpp
@@ -2312,6 +2312,7 @@ void Snmp::stop_poll_thread()
#ifdef _THREADS
// stop the thread
m_bThreadRunning = false;
+ eventListHolder->SNMPExitMainLoop();
// Wait for the working thread to stop....
#ifdef WIN32
--
1.5.5.6
--azLHFNyN32YCQGCU--
More information about the AGENTPP
mailing list