mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 22:15:52 +00:00
Reduce Beast public interface and eliminate unused code:
Beast includes a lot of code for encapsulating cross-platform differences which are not used or needed by rippled. Additionally, a lot of that code implements functionality that is available from the standard library. This moves away from custom implementations of features that the standard library provides and reduces the number of platform-specific interfaces andfeatures that Beast makes available. Highlights include: * Use std:: instead of beast implementations when possible * Reduce the use of beast::String in public interfaces * Remove Windows-specific COM and Registry code * Reduce the public interface of beast::File * Reduce the public interface of beast::SystemStats * Remove unused sysctl/getsysinfo functions * Remove beast::Logger
This commit is contained in:
committed by
Vinnie Falco
parent
fefdb32d08
commit
186ca9c235
@@ -23,33 +23,7 @@
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
/*
|
||||
Note that a lot of methods that you'd expect to find in this file actually
|
||||
live in beast_posix_SharedCode.h!
|
||||
*/
|
||||
|
||||
//==============================================================================
|
||||
void Process::setPriority (const ProcessPriority prior)
|
||||
{
|
||||
const int policy = (prior <= NormalPriority) ? SCHED_OTHER : SCHED_RR;
|
||||
const int minp = sched_get_priority_min (policy);
|
||||
const int maxp = sched_get_priority_max (policy);
|
||||
|
||||
struct sched_param param;
|
||||
|
||||
switch (prior)
|
||||
{
|
||||
case LowPriority:
|
||||
case NormalPriority: param.sched_priority = 0; break;
|
||||
case HighPriority: param.sched_priority = minp + (maxp - minp) / 4; break;
|
||||
case RealtimePriority: param.sched_priority = minp + (3 * (maxp - minp) / 4); break;
|
||||
default: bassertfalse; break;
|
||||
}
|
||||
|
||||
pthread_setschedparam (pthread_self(), policy, ¶m);
|
||||
}
|
||||
|
||||
bool beast_isRunningUnderDebugger()
|
||||
{
|
||||
static char testResult = 0;
|
||||
@@ -73,17 +47,4 @@ bool Process::isRunningUnderDebugger()
|
||||
return beast_isRunningUnderDebugger();
|
||||
}
|
||||
|
||||
// TODO(tom): raisePrivilege and lowerPrivilege don't seem to be called. If we
|
||||
// start using them, we should deal with the return codes of setreuid() and
|
||||
// setregid().
|
||||
static bool swapUserAndEffectiveUser()
|
||||
{
|
||||
auto r1 = setreuid (geteuid(), getuid());
|
||||
auto r2 = setregid (getegid(), getgid());
|
||||
return !(r1 || r2);
|
||||
}
|
||||
|
||||
void Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); }
|
||||
void Process::lowerPrivilege() { if (geteuid() == 0 && getuid() != 0) swapUserAndEffectiveUser(); }
|
||||
|
||||
} // beast
|
||||
|
||||
Reference in New Issue
Block a user