mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Impose an upper limit on threads per threadpool.
Found by Coverity; Fixes CID 1268069
This commit is contained in:
parent
4a9f41e1ec
commit
a194385d56
@ -359,12 +359,17 @@ threadpool_queue_update(threadpool_t *pool,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Don't have more than this many threads per pool. */
|
||||||
|
#define MAX_THREADS 1024
|
||||||
|
|
||||||
/** Launch threads until we have <b>n</b>. */
|
/** Launch threads until we have <b>n</b>. */
|
||||||
static int
|
static int
|
||||||
threadpool_start_threads(threadpool_t *pool, int n)
|
threadpool_start_threads(threadpool_t *pool, int n)
|
||||||
{
|
{
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
if (n > MAX_THREADS)
|
||||||
|
n = MAX_THREADS;
|
||||||
|
|
||||||
tor_mutex_acquire(&pool->lock);
|
tor_mutex_acquire(&pool->lock);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user