Skip to content

Commit

Permalink
void the pitfalls of infinite nproc hard limit in Linux. This patch
Browse files Browse the repository at this point in the history
should be included in 4.1.1.
  • Loading branch information
abh3 committed Dec 2, 2014
1 parent e13eba1 commit 3132161
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Xrd/XrdScheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ XrdScheduler::XrdScheduler(XrdSysError *eP, XrdOucTrace *tP,
//
#if defined(__linux__) && defined(RLIMIT_NPROC)

// Get the resource thread limit and set to maximum
// Get the resource thread limit and set to maximum. In Linux this may be -1
// to indicate useless infnity, so we have to come up with a number, sigh.
//
if (!getrlimit(RLIMIT_NPROC, &rlim))
if (!getrlimit(RLIMIT_NPROC, &rlim) && rlim.rlim_max > 0)
{if (rlim.rlim_cur < rlim.rlim_max)
{rlim.rlim_cur = rlim.rlim_max;
setrlimit(RLIMIT_NPROC, &rlim);
Expand All @@ -131,7 +132,9 @@ XrdScheduler::XrdScheduler(XrdSysError *eP, XrdOucTrace *tP,
// Readjust our internal maximum to be the actual maximum
//
if (!getrlimit(RLIMIT_NPROC, &rlim))
max_Workers = static_cast<int>(rlim.rlim_cur);
{if (rlim.rlim_cur < 1) max_Workers = 127000;
else max_Workers = static_cast<int>(rlim.rlim_cur);
}
#endif

}
Expand Down Expand Up @@ -448,8 +451,8 @@ void XrdScheduler::setParms(int minw, int maxw, int avlw, int maxi, int once)
// get a consistent view of all the values
//
if (maxw <= 0) maxw = max_Workers;
if (minw < 0) minw = (maxw/10 ? maxw/10 : 1);
else if (minw > maxw) minw = maxw;
if (minw < 0) minw = min_Workers;
if (minw > maxw) minw = maxw;
if (avlw < 0) avlw = maxw/4*3;
else if (avlw > maxw) avlw = maxw;

Expand Down

0 comments on commit 3132161

Please sign in to comment.