Skip to content

Commit

Permalink
ResourceManager: Fix the way that resource limits is check
Browse files Browse the repository at this point in the history
Now if the limit is a negative value or zero, it's gracefully taken
as infitine

Change-Id: Icc425c94ee7d6386ee8660b4dc15da352c61983c
  • Loading branch information
jcaden committed Aug 2, 2016
1 parent 4bc4363 commit ad1fda4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions server/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down Expand Up @@ -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");
}
}
Expand Down

0 comments on commit ad1fda4

Please sign in to comment.