static void
checkOpenFiles (float limit_percent)
{
  int nOpenFiles;

  nOpenFiles = getNumberOfOpenFiles ();

  if (nOpenFiles > getMaxOpenFiles () * limit_percent ) {
    throw KurentoException (NOT_ENOUGH_RESOURCES, "Too many open files");
  }
}
static void
checkOpenFiles (float limit_percent)
{
  const rlim_t maxOpenFiles = getMaxOpenFiles ();
  if (maxOpenFiles <= 0 || maxOpenFiles == RLIM_INFINITY) {
    return;
  }

  const rlim_t maxOpenFilesKms = (rlim_t)(maxOpenFiles * limit_percent);
  const rlim_t nOpenFiles = (rlim_t)getNumberOfOpenFiles ();

  if (nOpenFiles > maxOpenFilesKms) {
    std::ostringstream oss;
    oss << "Reached KMS files limit: " << maxOpenFilesKms;
    std::string exMessage = oss.str();

    oss << " (system max: " << maxOpenFiles << ");"
        << " set a higher limit with `ulimit -Sn`, or in the KMS service settings (/etc/default/kurento-media-server)";
    std::string logMessage = oss.str();

    GST_WARNING ("%s", logMessage.c_str());
    throw KurentoException (NOT_ENOUGH_RESOURCES, exMessage);
  }
}