trivial: misc. trivial refactoring (#4104)

* minor statsd refactoring

* stacktrace refactoring

* spork typos + unused include

* need thread on windows builds
This commit is contained in:
PastaPastaPasta 2021-04-15 13:58:04 -04:00 committed by GitHub
parent 01dd958429
commit 91f4e71563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 21 deletions

View File

@ -11,7 +11,6 @@
#include <key.h>
#include <unordered_map>
#include <unordered_set>
class CSporkMessage;
class CSporkManager;
@ -192,7 +191,7 @@ public:
READWRITE(strVersion);
}
// we don't serialize pubkey ids because pubkeys should be
// hardcoded or be setted with cmdline or options, should
// hardcoded or be set with cmdline or options, should
// not reuse pubkeys from previous dashd run
LOCK(cs);
READWRITE(mapSporksByHash);
@ -284,7 +283,7 @@ public:
* a spork to be considered active.
*
* This value must be at least a majority of the total number of spork
* keys, and for obvious resons cannot be larger than that number.
* keys, and for obvious reasons cannot be larger than that number.
*/
bool SetMinSporkKeys(int minSporkKeys);

View File

@ -9,7 +9,6 @@
#include <stacktraces.h>
#include <fs.h>
#include <logging.h>
#include <random.h>
#include <streams.h>
#include <utilstrencodings.h>
@ -17,18 +16,18 @@
#include <map>
#include <vector>
#include <memory>
#include <thread>
#include <atomic>
#if WIN32
#include <windows.h>
#include <dbghelp.h>
#include <thread>
#else
#ifdef ENABLE_STACKTRACES
#include <execinfo.h>
#endif
#include <unistd.h>
#include <signal.h>
#include <csignal>
#endif
#if !WIN32
@ -49,7 +48,7 @@
#include <backtrace.h>
#endif
#include <string.h>
#include <cstring>
std::string DemangleSymbol(const std::string& name)
{
@ -356,8 +355,8 @@ static std::vector<stackframe_info> GetStackFrameInfos(const std::vector<uint64_
std::vector<stackframe_info> infos;
infos.reserve(stackframes.size());
for (size_t i = 0; i < stackframes.size(); i++) {
if (backtrace_pcinfo(GetLibBacktraceState(), stackframes[i], my_backtrace_full_callback, my_backtrace_error_callback, &infos)) {
for (uint64_t stackframe : stackframes) {
if (backtrace_pcinfo(GetLibBacktraceState(), stackframe, my_backtrace_full_callback, my_backtrace_error_callback, &infos)) {
break;
}
}
@ -499,9 +498,7 @@ static std::string GetCrashInfoStr(const crash_info& ci, size_t spaces)
std::vector<std::string> lstrs;
lstrs.reserve(ci.stackframeInfos.size());
for (size_t i = 0; i < ci.stackframeInfos.size(); i++) {
auto& si = ci.stackframeInfos[i];
for (const auto& si : ci.stackframeInfos) {
std::string lstr;
if (!si.filename.empty()) {
lstr += fs::path(si.filename).filename().string();

View File

@ -11,8 +11,6 @@
#include <cxxabi.h>
#include <tinyformat.h>
std::string DemangleSymbol(const std::string& name);
std::string GetPrettyExceptionStr(const std::exception_ptr& e);

View File

@ -35,10 +35,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <random.h>
#include <util.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
#include <cstdio>
statsd::StatsdClient statsClient;
@ -88,7 +86,7 @@ StatsdClient::~StatsdClient()
// close socket
CloseSocket(d->sock);
delete d;
d = NULL;
d = nullptr;
}
void StatsdClient::config(const std::string& host, int port, const std::string& ns)

View File

@ -53,13 +53,13 @@ class StatsdClient {
protected:
int init();
void cleanup(std::string& key);
static void cleanup(std::string& key);
protected:
struct _StatsdClientData* d;
};
}; // namespace statsd
} // namespace statsd
extern statsd::StatsdClient statsClient;