Enhancements

Fix rule generation in Surge configs.
Refactor log output for curl verbose logs.
Optimize codes.
This commit is contained in:
Tindy X committed 2023-12-06 15:25:53 +08:00
1 parent a0e25158f5
commit 043c1fdcb9
37 files changed
+317 -260

No files matched your search

+17 -2
View File
@@ -5,7 +5,9 @@
#include <sys/types.h>
#include <unistd.h>
#include "../handler/settings.h"
#include "handler/settings.h"
#include "defer.h"
#include "lock.h"
#include "logger.h"
std::string getTime(int type)
@@ -38,7 +40,20 @@ std::string getTime(int type)
static std::string get_thread_name()
{
static std::atomic_int counter = 0;
thread_local static std::string name = "Thread-" + std::to_string(counter++);
static std::map<std::thread::id, std::string> thread_names;
static RWLock lock;
std::thread::id id = std::this_thread::get_id();
lock.readLock();
if (thread_names.find(id) != thread_names.end())
{
defer(lock.readUnlock();)
return thread_names[id];
}
lock.readUnlock();
lock.writeLock();
std::string name = "Thread-" + std::to_string(++counter);
thread_names[id] = name;
lock.writeUnlock();
return name;
}