From ad1fda48096d1f0b18bf181560317ea04096c5f3 Mon Sep 17 00:00:00 2001 From: Jose Antonio Santos Cadenas Date: Tue, 2 Aug 2016 10:53:12 +0200 Subject: [PATCH] ResourceManager: Fix the way that resource limits is check Now if the limit is a negative value or zero, it's gracefully taken as infitine Change-Id: Icc425c94ee7d6386ee8660b4dc15da352c61983c --- server/ResourceManager.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/ResourceManager.cpp b/server/ResourceManager.cpp index 73f9c688e..d5ab3064d 100644 --- a/server/ResourceManager.cpp +++ b/server/ResourceManager.cpp @@ -85,10 +85,15 @@ static void checkThreads (float limit_percent) { int nThreads; + int maxThreads = getMaxThreads (); + + if (maxThreads <= 0) { + return; + } nThreads = getNumberOfThreads (); - if (nThreads > getMaxThreads () * limit_percent ) { + if (nThreads > maxThreads * limit_percent ) { throw KurentoException (NOT_ENOUGH_RESOURCES, "Too many threads"); } } @@ -128,10 +133,15 @@ static void checkOpenFiles (float limit_percent) { int nOpenFiles; + int maxOpenFiles = getMaxOpenFiles (); + + if (maxOpenFiles <= 0) { + return; + } nOpenFiles = getNumberOfOpenFiles (); - if (nOpenFiles > getMaxOpenFiles () * limit_percent ) { + if (nOpenFiles > maxOpenFiles * limit_percent ) { throw KurentoException (NOT_ENOUGH_RESOURCES, "Too many open files"); } }