mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
Fix a situation where some threadpool work items are never executed.
Fixes #6349
This commit is contained in:
parent
fdc2ef6190
commit
157de9f3bb
@ -272,8 +272,9 @@ void ThreadPool::ManagerThreadProc(void)
|
|||||||
int tthreads = wthreads - alive;
|
int tthreads = wthreads - alive;
|
||||||
|
|
||||||
/* Make sure there is at least one thread per CPU */
|
/* Make sure there is at least one thread per CPU */
|
||||||
if (alive + tthreads < std::max(boost::thread::hardware_concurrency(), 4U))
|
int ncput = std::max(boost::thread::hardware_concurrency() / QUEUECOUNT, 1U);
|
||||||
tthreads = 1 - alive;
|
if (alive + tthreads < ncput)
|
||||||
|
tthreads = ncput - alive;
|
||||||
|
|
||||||
/* Don't kill more than 8 threads at once. */
|
/* Don't kill more than 8 threads at once. */
|
||||||
if (tthreads < -8)
|
if (tthreads < -8)
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#define QUEUECOUNT 4
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A thread pool.
|
* A thread pool.
|
||||||
*
|
*
|
||||||
@ -118,7 +120,7 @@ private:
|
|||||||
boost::condition_variable m_MgmtCV;
|
boost::condition_variable m_MgmtCV;
|
||||||
bool m_Stopped;
|
bool m_Stopped;
|
||||||
|
|
||||||
Queue m_Queues[4];
|
Queue m_Queues[QUEUECOUNT];
|
||||||
|
|
||||||
void ManagerThreadProc(void);
|
void ManagerThreadProc(void);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user