mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 02:55:50 +00:00
Split thread and range stuff out of utils
This commit is contained in:
@@ -68,6 +68,39 @@ namespace boost
|
||||
};
|
||||
}
|
||||
|
||||
// VFALCO: Maybe not the best place for this but it sort of makes sense here
|
||||
|
||||
// VFALCO: NOTE, these three are unused.
|
||||
/*
|
||||
template<typename T> T range_check(const T& value, const T& minimum, const T& maximum)
|
||||
{
|
||||
if ((value < minimum) || (value > maximum))
|
||||
throw std::runtime_error("Value out of range");
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T> T range_check_min(const T& value, const T& minimum)
|
||||
{
|
||||
if (value < minimum)
|
||||
throw std::runtime_error("Value out of range");
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T> T range_check_max(const T& value, const T& maximum)
|
||||
{
|
||||
if (value > maximum)
|
||||
throw std::runtime_error("Value out of range");
|
||||
return value;
|
||||
}
|
||||
*/
|
||||
|
||||
template<typename T, typename U> T range_check_cast(const U& value, const T& minimum, const T& maximum)
|
||||
{
|
||||
if ((value < minimum) || (value > maximum))
|
||||
throw std::runtime_error("Value out of range");
|
||||
return static_cast<T>(value);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -66,6 +66,8 @@
|
||||
#include "memory/ripple_ByteOrder.cpp"
|
||||
|
||||
#include "system/ripple_RandomNumbers.cpp"
|
||||
#include "system/ripple_ThreadName.cpp"
|
||||
#include "system/ripple_Time.cpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
//#pragma warning (pop)
|
||||
|
||||
@@ -38,6 +38,11 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#if BOOST_VERSION < 104700
|
||||
#error Boost 1.47 or later is required
|
||||
#endif
|
||||
|
||||
// Log
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
// Forward declaration
|
||||
@@ -68,6 +73,9 @@ namespace boost {
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
// RippleTime
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
// ByteOrder
|
||||
#ifdef WIN32
|
||||
// (nothing)
|
||||
@@ -103,5 +111,7 @@ namespace boost {
|
||||
|
||||
#include "system/ripple_PlatformMacros.h"
|
||||
#include "system/ripple_RandomNumbers.h"
|
||||
#include "system/ripple_ThreadName.h"
|
||||
#include "system/ripple_Time.h"
|
||||
|
||||
#endif
|
||||
|
||||
82
modules/ripple_basics/system/ripple_ThreadName.cpp
Normal file
82
modules/ripple_basics/system/ripple_ThreadName.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
// VFALCO: TODO, use VFLIB_MSVC macro instead
|
||||
#if _MSC_VER
|
||||
|
||||
void setCallingThreadName (char const* threadName)
|
||||
{
|
||||
struct ThreadInfo
|
||||
{
|
||||
DWORD dwType;
|
||||
LPCSTR szName;
|
||||
DWORD dwThreadID;
|
||||
DWORD dwFlags;
|
||||
};
|
||||
|
||||
ThreadInfo info;
|
||||
|
||||
info.dwType = 0x1000;
|
||||
info.szName = threadName;
|
||||
info.dwThreadID = GetCurrentThreadId ();
|
||||
info.dwFlags = 0;
|
||||
|
||||
__try
|
||||
{
|
||||
// This is a VisualStudio specific exception
|
||||
RaiseException (0x406d1388, 0, sizeof (info) / sizeof (ULONG_PTR), (ULONG_PTR*) &info);
|
||||
}
|
||||
__except (EXCEPTION_CONTINUE_EXECUTION)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#ifdef PR_SET_NAME
|
||||
#define HAVE_NAME_THREAD
|
||||
extern void setCallingThreadName (const char* n)
|
||||
{
|
||||
static std::string pName;
|
||||
|
||||
if (pName.empty())
|
||||
{
|
||||
std::ifstream cLine("/proc/self/cmdline", std::ios::in);
|
||||
cLine >> pName;
|
||||
if (pName.empty())
|
||||
pName = "rippled";
|
||||
else
|
||||
{
|
||||
size_t zero = pName.find_first_of('\0');
|
||||
if ((zero != std::string::npos) && (zero != 0))
|
||||
pName = pName.substr(0, zero);
|
||||
size_t slash = pName.find_last_of('/');
|
||||
if (slash != std::string::npos)
|
||||
pName = pName.substr(slash + 1);
|
||||
}
|
||||
pName += " ";
|
||||
}
|
||||
|
||||
prctl(PR_SET_NAME, (pName + n).c_str(), 0, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_NAME_THREAD
|
||||
extern void setCallingThreadName(const char*)
|
||||
{ ; }
|
||||
#endif
|
||||
#endif
|
||||
24
modules/ripple_basics/system/ripple_ThreadName.h
Normal file
24
modules/ripple_basics/system/ripple_ThreadName.h
Normal file
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_THREADNAME_H
|
||||
#define RIPPLE_THREADNAME_H
|
||||
|
||||
extern void setCallingThreadName (char const*);
|
||||
|
||||
#endif
|
||||
54
modules/ripple_basics/system/ripple_Time.cpp
Normal file
54
modules/ripple_basics/system/ripple_Time.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
//
|
||||
// Time support
|
||||
// We have our own epoch.
|
||||
//
|
||||
|
||||
boost::posix_time::ptime ptEpoch()
|
||||
{
|
||||
return boost::posix_time::ptime(boost::gregorian::date(2000, boost::gregorian::Jan, 1));
|
||||
}
|
||||
|
||||
int iToSeconds(boost::posix_time::ptime ptWhen)
|
||||
{
|
||||
return ptWhen.is_not_a_date_time()
|
||||
? -1
|
||||
: (ptWhen-ptEpoch()).total_seconds();
|
||||
}
|
||||
|
||||
// Convert our time in seconds to a ptime.
|
||||
boost::posix_time::ptime ptFromSeconds(int iSeconds)
|
||||
{
|
||||
return iSeconds < 0
|
||||
? boost::posix_time::ptime(boost::posix_time::not_a_date_time)
|
||||
: ptEpoch() + boost::posix_time::seconds(iSeconds);
|
||||
}
|
||||
|
||||
// Convert from our time to UNIX time in seconds.
|
||||
uint64_t utFromSeconds(int iSeconds)
|
||||
{
|
||||
boost::posix_time::time_duration tdDelta =
|
||||
boost::posix_time::ptime(boost::gregorian::date(2000, boost::gregorian::Jan, 1))
|
||||
-boost::posix_time::ptime(boost::gregorian::date(1970, boost::gregorian::Jan, 1))
|
||||
+boost::posix_time::seconds(iSeconds)
|
||||
;
|
||||
|
||||
return tdDelta.total_seconds();
|
||||
}
|
||||
27
modules/ripple_basics/system/ripple_Time.h
Normal file
27
modules/ripple_basics/system/ripple_Time.h
Normal file
@@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_TIME_H
|
||||
#define RIPPLE_TIME_H
|
||||
|
||||
boost::posix_time::ptime ptEpoch();
|
||||
int iToSeconds(boost::posix_time::ptime ptWhen);
|
||||
boost::posix_time::ptime ptFromSeconds(int iSeconds);
|
||||
uint64_t utFromSeconds(int iSeconds);
|
||||
|
||||
#endif
|
||||
@@ -216,6 +216,18 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="modules\ripple_basics\system\ripple_ThreadName.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="modules\ripple_basics\system\ripple_Time.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="modules\ripple_client\ripple_client.cpp" />
|
||||
<ClCompile Include="modules\ripple_db\ripple_db.cpp" />
|
||||
<ClCompile Include="modules\ripple_json\json\json_reader.cpp">
|
||||
@@ -1198,6 +1210,8 @@
|
||||
<ClInclude Include="modules\ripple_basics\ripple_basics.h" />
|
||||
<ClInclude Include="modules\ripple_basics\system\ripple_PlatformMacros.h" />
|
||||
<ClInclude Include="modules\ripple_basics\system\ripple_RandomNumbers.h" />
|
||||
<ClInclude Include="modules\ripple_basics\system\ripple_ThreadName.h" />
|
||||
<ClInclude Include="modules\ripple_basics\system\ripple_Time.h" />
|
||||
<ClInclude Include="modules\ripple_basics\types\ripple_IntegerTypes.h" />
|
||||
<ClInclude Include="modules\ripple_client\ripple_client.h" />
|
||||
<ClInclude Include="modules\ripple_db\ripple_db.h" />
|
||||
|
||||
@@ -765,6 +765,12 @@
|
||||
<ClCompile Include="modules\ripple_basics\system\ripple_RandomNumbers.cpp">
|
||||
<Filter>1. Modules\ripple_basics\system</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="modules\ripple_basics\system\ripple_Time.cpp">
|
||||
<Filter>1. Modules\ripple_basics\system</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="modules\ripple_basics\system\ripple_ThreadName.cpp">
|
||||
<Filter>1. Modules\ripple_basics\system</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="database\sqlite3ext.h">
|
||||
@@ -1424,6 +1430,12 @@
|
||||
<ClInclude Include="modules\ripple_basics\system\ripple_RandomNumbers.h">
|
||||
<Filter>1. Modules\ripple_basics\system</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="modules\ripple_basics\system\ripple_Time.h">
|
||||
<Filter>1. Modules\ripple_basics\system</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="modules\ripple_basics\system\ripple_ThreadName.h">
|
||||
<Filter>1. Modules\ripple_basics\system</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="SConstruct" />
|
||||
|
||||
@@ -112,13 +112,13 @@ void sigIntHandler(int)
|
||||
|
||||
static void runAux(boost::asio::io_service& svc)
|
||||
{
|
||||
NameThread("aux");
|
||||
setCallingThreadName("aux");
|
||||
svc.run();
|
||||
}
|
||||
|
||||
static void runIO(boost::asio::io_service& io)
|
||||
{
|
||||
NameThread("io");
|
||||
setCallingThreadName("io");
|
||||
io.run();
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ void JobQueue::IOThread(boost::mutex::scoped_lock& sl)
|
||||
{ // call with a lock
|
||||
++mIOThreadCount;
|
||||
sl.unlock();
|
||||
NameThread("IO+");
|
||||
setCallingThreadName("IO+");
|
||||
try
|
||||
{
|
||||
mIOService.poll();
|
||||
@@ -282,7 +282,7 @@ void JobQueue::IOThread(boost::mutex::scoped_lock& sl)
|
||||
{
|
||||
WriteLog (lsWARNING, JobQueue) << "Exception in IOThread";
|
||||
}
|
||||
NameThread("waiting");
|
||||
setCallingThreadName("waiting");
|
||||
sl.lock();
|
||||
--mIOThreadCount;
|
||||
}
|
||||
@@ -292,7 +292,7 @@ void JobQueue::threadEntry()
|
||||
boost::mutex::scoped_lock sl(mJobLock);
|
||||
while (1)
|
||||
{
|
||||
NameThread("waiting");
|
||||
setCallingThreadName("waiting");
|
||||
// bool didIO = false;
|
||||
while (mJobSet.empty() && !mShuttingDown)
|
||||
{
|
||||
@@ -325,7 +325,7 @@ void JobQueue::threadEntry()
|
||||
|
||||
++(mJobCounts[type].second);
|
||||
sl.unlock();
|
||||
NameThread(Job::toString(type));
|
||||
setCallingThreadName(Job::toString(type));
|
||||
WriteLog (lsTRACE, JobQueue) << "Doing " << Job::toString(type) << " job";
|
||||
job.doJob();
|
||||
} // must destroy job without holding lock
|
||||
|
||||
@@ -324,7 +324,7 @@ static void LogDeadLock(int dlTime)
|
||||
|
||||
void LoadManager::threadEntry()
|
||||
{
|
||||
NameThread("loadmgr");
|
||||
setCallingThreadName("loadmgr");
|
||||
boost::posix_time::ptime t = boost::posix_time::microsec_clock::universal_time();
|
||||
while (1)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ DECLARE_INSTANCE(WebSocketConnection);
|
||||
|
||||
void WSDoor::startListening()
|
||||
{
|
||||
NameThread("websocket");
|
||||
setCallingThreadName("websocket");
|
||||
// Generate a single SSL context for use by all connections.
|
||||
boost::shared_ptr<boost::asio::ssl::context> mCtx;
|
||||
mCtx = boost::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23);
|
||||
|
||||
@@ -128,7 +128,7 @@ void printHelp(const po::options_description& desc)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
NameThread("main");
|
||||
setCallingThreadName("main");
|
||||
int iResult = 0;
|
||||
po::variables_map vm; // Map of options.
|
||||
|
||||
@@ -269,14 +269,14 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
// No arguments. Run server.
|
||||
setupServer();
|
||||
NameThread("io");
|
||||
setCallingThreadName("io");
|
||||
startServer();
|
||||
InstanceType::shutdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Have a RPC command.
|
||||
NameThread("rpc");
|
||||
setCallingThreadName("rpc");
|
||||
std::vector<std::string> vCmd = vm["parameters"].as<std::vector<std::string> >();
|
||||
|
||||
iResult = commandLineRPC(vCmd);
|
||||
|
||||
@@ -28,43 +28,6 @@
|
||||
#include "utils.h"
|
||||
#include "uint256.h"
|
||||
|
||||
//
|
||||
// Time support
|
||||
// We have our own epoch.
|
||||
//
|
||||
|
||||
boost::posix_time::ptime ptEpoch()
|
||||
{
|
||||
return boost::posix_time::ptime(boost::gregorian::date(2000, boost::gregorian::Jan, 1));
|
||||
}
|
||||
|
||||
int iToSeconds(boost::posix_time::ptime ptWhen)
|
||||
{
|
||||
return ptWhen.is_not_a_date_time()
|
||||
? -1
|
||||
: (ptWhen-ptEpoch()).total_seconds();
|
||||
}
|
||||
|
||||
// Convert our time in seconds to a ptime.
|
||||
boost::posix_time::ptime ptFromSeconds(int iSeconds)
|
||||
{
|
||||
return iSeconds < 0
|
||||
? boost::posix_time::ptime(boost::posix_time::not_a_date_time)
|
||||
: ptEpoch() + boost::posix_time::seconds(iSeconds);
|
||||
}
|
||||
|
||||
// Convert from our time to UNIX time in seconds.
|
||||
uint64_t utFromSeconds(int iSeconds)
|
||||
{
|
||||
boost::posix_time::time_duration tdDelta =
|
||||
boost::posix_time::ptime(boost::gregorian::date(2000, boost::gregorian::Jan, 1))
|
||||
-boost::posix_time::ptime(boost::gregorian::date(1970, boost::gregorian::Jan, 1))
|
||||
+boost::posix_time::seconds(iSeconds)
|
||||
;
|
||||
|
||||
return tdDelta.total_seconds();
|
||||
}
|
||||
|
||||
//
|
||||
// DH support
|
||||
//
|
||||
@@ -97,39 +60,6 @@ DH* DH_der_load(const std::string& strDer)
|
||||
return d2i_DHparams(NULL, &pbuf, strDer.size());
|
||||
}
|
||||
|
||||
#ifdef PR_SET_NAME
|
||||
#define HAVE_NAME_THREAD
|
||||
extern void NameThread(const char* n)
|
||||
{
|
||||
static std::string pName;
|
||||
|
||||
if (pName.empty())
|
||||
{
|
||||
std::ifstream cLine("/proc/self/cmdline", std::ios::in);
|
||||
cLine >> pName;
|
||||
if (pName.empty())
|
||||
pName = "rippled";
|
||||
else
|
||||
{
|
||||
size_t zero = pName.find_first_of('\0');
|
||||
if ((zero != std::string::npos) && (zero != 0))
|
||||
pName = pName.substr(0, zero);
|
||||
size_t slash = pName.find_last_of('/');
|
||||
if (slash != std::string::npos)
|
||||
pName = pName.substr(slash + 1);
|
||||
}
|
||||
pName += " ";
|
||||
}
|
||||
|
||||
prctl(PR_SET_NAME, (pName + n).c_str(), 0, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_NAME_THREAD
|
||||
extern void NameThread(const char*)
|
||||
{ ; }
|
||||
#endif
|
||||
|
||||
#ifdef __unix__
|
||||
|
||||
static pid_t pManager = static_cast<pid_t>(0);
|
||||
@@ -175,14 +105,14 @@ std::string DoSustain()
|
||||
_exit(0);
|
||||
if (pChild == 0)
|
||||
{
|
||||
NameThread("main");
|
||||
setCallingThreadName("main");
|
||||
signal(SIGINT, SIG_DFL);
|
||||
signal(SIGHUP, SIG_DFL);
|
||||
signal(SIGUSR1, SIG_DFL);
|
||||
signal(SIGUSR2, SIG_DFL);
|
||||
return str(boost::format("Launching child %d") % childCount);;
|
||||
}
|
||||
NameThread(boost::str(boost::format("#%d") % childCount).c_str());
|
||||
setCallingThreadName(boost::str(boost::format("#%d") % childCount).c_str());
|
||||
do
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
#ifndef __UTILS__
|
||||
#define __UTILS__
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#if BOOST_VERSION < 104700
|
||||
#error Boost 1.47 or later is required
|
||||
#endif
|
||||
|
||||
#include <openssl/dh.h>
|
||||
|
||||
#define nothing() do {} while (0)
|
||||
@@ -18,47 +11,9 @@
|
||||
|
||||
#define isSetBit(x,y) (!!((x) & (y)))
|
||||
|
||||
boost::posix_time::ptime ptEpoch();
|
||||
int iToSeconds(boost::posix_time::ptime ptWhen);
|
||||
boost::posix_time::ptime ptFromSeconds(int iSeconds);
|
||||
uint64_t utFromSeconds(int iSeconds);
|
||||
|
||||
DH* DH_der_load(const std::string& strDer);
|
||||
std::string DH_der_gen(int iKeyLength);
|
||||
|
||||
// VFALCO: NOTE, these three are unused.
|
||||
/*
|
||||
template<typename T> T range_check(const T& value, const T& minimum, const T& maximum)
|
||||
{
|
||||
if ((value < minimum) || (value > maximum))
|
||||
throw std::runtime_error("Value out of range");
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T> T range_check_min(const T& value, const T& minimum)
|
||||
{
|
||||
if (value < minimum)
|
||||
throw std::runtime_error("Value out of range");
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T> T range_check_max(const T& value, const T& maximum)
|
||||
{
|
||||
if (value > maximum)
|
||||
throw std::runtime_error("Value out of range");
|
||||
return value;
|
||||
}
|
||||
*/
|
||||
|
||||
template<typename T, typename U> T range_check_cast(const U& value, const T& minimum, const T& maximum)
|
||||
{
|
||||
if ((value < minimum) || (value > maximum))
|
||||
throw std::runtime_error("Value out of range");
|
||||
return static_cast<T>(value);
|
||||
}
|
||||
|
||||
extern void NameThread(const char *);
|
||||
|
||||
extern bool HaveSustain();
|
||||
extern std::string StopSustain();
|
||||
extern std::string DoSustain();
|
||||
|
||||
Reference in New Issue
Block a user