Skip to content

Commit 7d66598

Browse files
committed
Update deps
1 parent e14ebbb commit 7d66598

18 files changed

+114
-107
lines changed

atframework/atframe_utils

atframework/cmake-toolset

docs/experience/protocol_test.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ char test_buffer[] = "hello world!";
8282
packed_buffer.assign(reinterpret_cast<const unsigned char *>(fbb.GetBufferPointer()),
8383
reinterpret_cast<const unsigned char *>(fbb.GetBufferPointer()) + fbb.GetSize());
8484
std::stringstream so;
85-
util::string::serialization(packed_buffer.data(), packed_buffer.size(), so);
85+
atfw::util::string::serialization(packed_buffer.data(), packed_buffer.size(), so);
8686
std::cout<< "flatbuffers encoded(size=" << packed_buffer.size() << "): " << so.str() << std::endl;
8787
}
8888
```
@@ -186,7 +186,7 @@ char test_buffer[] = "hello world!";
186186
msgpack::pack(ss, m_src);
187187
packed_buffer = ss.str();
188188
std::stringstream so;
189-
util::string::serialization(packed_buffer.data(), packed_buffer.size(), so);
189+
atfw::util::string::serialization(packed_buffer.data(), packed_buffer.size(), so);
190190
std::cout<< "msgpack encoded(size=" << packed_buffer.size() << "): " << so.str() << std::endl;
191191
}
192192
```
@@ -270,7 +270,7 @@ char test_buffer[] = "hello world!";
270270

271271
m_src->SerializeToString(&packed_buffer);
272272
std::stringstream so;
273-
util::string::serialization(packed_buffer.data(), packed_buffer.size(), so);
273+
atfw::util::string::serialization(packed_buffer.data(), packed_buffer.size(), so);
274274
std::cout << "arena(allocated= " << arena.SpaceAllocated() << ", used= " << arena.SpaceUsed() << "), protobuf encoded(size=" << packed_buffer.size()
275275
<< "): " << so.str() << std::endl;
276276
}

include/atbus_connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct timer_desc_ls {
4141
using type = std::list<pair_type>;
4242
};
4343

44-
class connection final : public util::design_pattern::noncopyable {
44+
class connection final : public atfw::util::design_pattern::noncopyable {
4545
public:
4646
using ptr_t = std::shared_ptr<connection>;
4747

include/atbus_endpoint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class ATBUS_MACRO_API endpoint_subnet_range {
9393
ATBUS_MACRO_BUSID_TYPE max_id_;
9494
};
9595

96-
class endpoint final : public util::design_pattern::noncopyable {
96+
class endpoint final : public atfw::util::design_pattern::noncopyable {
9797
public:
9898
using bus_id_t = ATBUS_MACRO_BUSID_TYPE;
9999
using ptr_t = std::shared_ptr<endpoint>;

include/atbus_node.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class node_access_controller {
4949
static void remove_ping_timer(node &n, timer_desc_ls<std::weak_ptr<endpoint> >::type::iterator &inout);
5050
};
5151

52-
class node final : public util::design_pattern::noncopyable {
52+
class node final : public atfw::util::design_pattern::noncopyable {
5353
public:
5454
using ptr_t = std::shared_ptr<node>;
5555
using msg_builder_ref_t = ::atbus::protocol::msg &;
@@ -104,17 +104,17 @@ class node final : public util::design_pattern::noncopyable {
104104
std::vector<endpoint_subnet_conf> subnets; /** 子网范围 **/
105105
std::bitset<conf_flag_t::EN_CONF_MAX> flags; /** 开关配置 **/
106106
std::string parent_address; /** 父节点地址 **/
107-
int loop_times; /** 消息循环次数限制,防止某些通道繁忙把其他通道堵死 **/
108-
int ttl; /** 消息转发跳转限制 **/
107+
int loop_times; /** 消息循环次数限制,防止某些通道繁忙把其他通道堵死 **/
108+
int ttl; /** 消息转发跳转限制 **/
109109
int32_t protocol_version;
110110
int32_t protocol_minimal_version;
111111

112112
// ===== 连接配置 =====
113113
int backlog;
114-
time_t first_idle_timeout; /** 第一个包允许的空闲时间,秒 **/
115-
time_t ping_interval; /** ping包间隔,秒 **/
116-
time_t retry_interval; /** 重试包间隔,秒 **/
117-
size_t fault_tolerant; /** 容错次数,次 **/
114+
time_t first_idle_timeout; /** 第一个包允许的空闲时间,秒 **/
115+
time_t ping_interval; /** ping包间隔,秒 **/
116+
time_t retry_interval; /** 重试包间隔,秒 **/
117+
size_t fault_tolerant; /** 容错次数,次 **/
118118
size_t access_token_max_number; /** 最大access token数量,请不要设置的太大,验证次数最大可能是N^2 **/
119119
std::vector<std::vector<unsigned char> > access_tokens; /** access token列表 **/
120120
bool overwrite_listen_path; /** 是否覆盖已存在的listen path(unix socket) **/
@@ -698,7 +698,7 @@ class node final : public util::design_pattern::noncopyable {
698698
conf_t conf_;
699699
std::string hash_code_;
700700
std::weak_ptr<node> watcher_; // just like std::shared_from_this<T>
701-
util::lock::seq_alloc_u64 msg_seq_alloc_;
701+
atfw::util::lock::seq_alloc_u64 msg_seq_alloc_;
702702

703703
// 引用的资源标记(释放时要保证这些资源引用被移除)
704704
std::set<void *> ref_objs_;
@@ -752,7 +752,7 @@ class node final : public util::design_pattern::noncopyable {
752752
stat_info_t();
753753
};
754754
stat_info_t stat_;
755-
::util::random::xoshiro256_starstar random_engine_;
755+
::atfw::util::random::xoshiro256_starstar random_engine_;
756756

757757
// 调试辅助函数
758758
public:

include/detail/libatbus_channel_types.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ struct ATBUS_MACRO_API_HEAD_ONLY io_stream_channel {
188188

189189
int error_code; // 记录外部的错误码
190190
// 统计信息
191-
util::lock::seq_alloc_u32 active_reqs; // 正在进行的req数量
192-
size_t read_net_eagain_count; // 读到的网络重试错误数量
193-
size_t read_check_block_size_failed_count; // 读到的数据块长度检查错误数量
194-
size_t read_check_hash_failed_count; // 读到的数据hash检查错误数量
191+
atfw::util::lock::seq_alloc_u32 active_reqs; // 正在进行的req数量
192+
size_t read_net_eagain_count; // 读到的网络重试错误数量
193+
size_t read_check_block_size_failed_count; // 读到的数据块长度检查错误数量
194+
size_t read_check_hash_failed_count; // 读到的数据hash检查错误数量
195195

196196
// 自定义数据区域
197197
void *data;

src/atbus_connection.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ namespace detail {
3232
static int try_flock_file(const std::string &lock_path) {
3333
// mkdir if dir not exists
3434
std::string dirname;
35-
if (util::file_system::dirname(lock_path.c_str(), lock_path.size(), dirname)) {
36-
if (!util::file_system::is_exist(dirname.c_str())) {
37-
util::file_system::mkdir(dirname.c_str(), true);
35+
if (atfw::util::file_system::dirname(lock_path.c_str(), lock_path.size(), dirname)) {
36+
if (!atfw::util::file_system::is_exist(dirname.c_str())) {
37+
atfw::util::file_system::mkdir(dirname.c_str(), true);
3838
}
3939
}
4040

@@ -203,7 +203,7 @@ ATBUS_MACRO_API int connection::listen(const char *addr_str) {
203203
if (0 == UTIL_STRFUNC_STRNCASE_CMP("mem", address_.scheme.c_str(), 3)) {
204204
channel::mem_channel *mem_chann = nullptr;
205205
intptr_t ad;
206-
util::string::str2int(ad, address_.host.c_str());
206+
atfw::util::string::str2int(ad, address_.host.c_str());
207207
int res = channel::mem_attach(reinterpret_cast<void *>(ad), conf.recv_buffer_size, &mem_chann, nullptr);
208208
if (res < 0) {
209209
res = channel::mem_init(reinterpret_cast<void *>(ad), conf.recv_buffer_size, &mem_chann, nullptr);
@@ -264,8 +264,8 @@ ATBUS_MACRO_API int connection::listen(const char *addr_str) {
264264
// Unix sock的listen的地址应该转为绝对地址,方便跨组连接时可以不依赖相对目录
265265
// Unix sock也必须共享Host
266266
if (0 == UTIL_STRFUNC_STRNCASE_CMP("unix", address_.scheme.c_str(), 4)) {
267-
if (false == util::file_system::is_abs_path(address_.host.c_str())) {
268-
std::string abs_host_path = util::file_system::get_abs_path(address_.host.c_str());
267+
if (false == atfw::util::file_system::is_abs_path(address_.host.c_str())) {
268+
std::string abs_host_path = atfw::util::file_system::get_abs_path(address_.host.c_str());
269269
size_t max_addr_size = ::atbus::channel::io_stream_get_max_unix_socket_length();
270270
if (max_addr_size > 0 && abs_host_path.size() <= max_addr_size) {
271271
address_.host = abs_host_path;
@@ -291,8 +291,8 @@ ATBUS_MACRO_API int connection::listen(const char *addr_str) {
291291
}
292292
#endif
293293

294-
if (util::file_system::is_exist(address_.host.c_str())) {
295-
if (false == util::file_system::remove(address_.host.c_str())) {
294+
if (atfw::util::file_system::is_exist(address_.host.c_str())) {
295+
if (false == atfw::util::file_system::remove(address_.host.c_str())) {
296296
ATBUS_FUNC_NODE_ERROR(*owner_, get_binding(), this, EN_ATBUS_ERR_PIPE_REMOVE_FAILED, 0);
297297
return EN_ATBUS_ERR_PIPE_REMOVE_FAILED;
298298
}
@@ -335,7 +335,7 @@ ATBUS_MACRO_API int connection::connect(const char *addr_str) {
335335
if (0 == UTIL_STRFUNC_STRNCASE_CMP("mem", address_.scheme.c_str(), 3)) {
336336
channel::mem_channel *mem_chann = nullptr;
337337
intptr_t ad;
338-
util::string::str2int(ad, address_.host.c_str());
338+
atfw::util::string::str2int(ad, address_.host.c_str());
339339
int res = channel::mem_attach(reinterpret_cast<void *>(ad), conf.recv_buffer_size, &mem_chann, nullptr);
340340
if (res < 0) {
341341
res = channel::mem_init(reinterpret_cast<void *>(ad), conf.recv_buffer_size, &mem_chann, nullptr);

src/atbus_node.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
#include <ctime>
2727
#include <functional>
2828
#include <sstream>
29-
#if !(defined(THREAD_TLS_USE_PTHREAD) && THREAD_TLS_USE_PTHREAD) && __cplusplus >= 201103L
29+
#if !(defined(ATFRAMEWORK_UTILS_THREAD_TLS_USE_PTHREAD) && ATFRAMEWORK_UTILS_THREAD_TLS_USE_PTHREAD) && \
30+
__cplusplus >= 201103L
3031
# include <mutex>
3132
#endif
3233

@@ -44,7 +45,7 @@
4445

4546
namespace atbus {
4647

47-
#if defined(THREAD_TLS_USE_PTHREAD) && THREAD_TLS_USE_PTHREAD
48+
#if defined(ATFRAMEWORK_UTILS_THREAD_TLS_USE_PTHREAD) && ATFRAMEWORK_UTILS_THREAD_TLS_USE_PTHREAD
4849
namespace detail {
4950
static pthread_once_t gt_atbus_node_global_init_once = PTHREAD_ONCE_INIT;
5051
static void atbus_node_global_init_once() {
@@ -148,7 +149,7 @@ node::node() : state_(state_t::CREATED), ev_loop_(nullptr), static_buffer_(nullp
148149

149150
flags_.reset();
150151

151-
#if defined(THREAD_TLS_USE_PTHREAD) && THREAD_TLS_USE_PTHREAD
152+
#if defined(ATFRAMEWORK_UTILS_THREAD_TLS_USE_PTHREAD) && ATFRAMEWORK_UTILS_THREAD_TLS_USE_PTHREAD
152153
(void)pthread_once(&detail::gt_atbus_node_global_init_once, detail::atbus_node_global_init_once);
153154
#elif __cplusplus >= 201103L
154155
std::call_once(detail::gt_atbus_node_global_init_once, detail::atbus_node_global_init_once);
@@ -264,9 +265,9 @@ ATBUS_MACRO_API int node::start(const start_conf_t &start_conf) {
264265

265266
// 初始化时间
266267
if (0 == start_conf.timer_sec && 0 == start_conf.timer_usec) {
267-
util::time::time_utility::update();
268-
event_timer_.sec = util::time::time_utility::get_sys_now();
269-
event_timer_.usec = util::time::time_utility::get_now_usec();
268+
atfw::util::time::time_utility::update();
269+
event_timer_.sec = atfw::util::time::time_utility::get_sys_now();
270+
event_timer_.usec = atfw::util::time::time_utility::get_now_usec();
270271
} else {
271272
event_timer_.sec = start_conf.timer_sec;
272273
event_timer_.usec = start_conf.timer_usec;
@@ -1194,8 +1195,8 @@ ATBUS_MACRO_API bool node::generate_access_hash(size_t idx, uint32_t &salt, uint
11941195

11951196
salt = static_cast<uint32_t>(random_engine_.random());
11961197
uint64_t out[2] = {0};
1197-
::util::hash::murmur_hash3_x64_128(reinterpret_cast<const void *>(&conf_.access_tokens[idx][0]),
1198-
static_cast<int>(conf_.access_tokens[idx].size()), salt, out);
1198+
::atfw::util::hash::murmur_hash3_x64_128(reinterpret_cast<const void *>(&conf_.access_tokens[idx][0]),
1199+
static_cast<int>(conf_.access_tokens[idx].size()), salt, out);
11991200
hashval1 = out[0];
12001201
hashval2 = out[1];
12011202
return true;
@@ -1209,8 +1210,8 @@ ATBUS_MACRO_API bool node::check_access_hash(const uint32_t salt, const uint64_t
12091210

12101211
for (size_t i = 0; i < conf_.access_tokens.size(); ++i) {
12111212
uint64_t out[2] = {0};
1212-
::util::hash::murmur_hash3_x64_128(reinterpret_cast<const void *>(&conf_.access_tokens[i][0]),
1213-
static_cast<int>(conf_.access_tokens[i].size()), salt, out);
1213+
::atfw::util::hash::murmur_hash3_x64_128(reinterpret_cast<const void *>(&conf_.access_tokens[i][0]),
1214+
static_cast<int>(conf_.access_tokens[i].size()), salt, out);
12141215
if (hashval1 == out[0] && hashval2 == out[1]) {
12151216
return true;
12161217
}
@@ -1334,8 +1335,8 @@ ATBUS_MACRO_API const std::string &node::get_hostname() {
13341335
}
13351336
if (dump_index < sizeof(inter_addr->phys_addr)) {
13361337
one_addr.resize((sizeof(inter_addr->phys_addr) - dump_index) * 2);
1337-
util::string::dumphex(inter_addr->phys_addr + dump_index, (sizeof(inter_addr->phys_addr) - dump_index),
1338-
&one_addr[0]);
1338+
atfw::util::string::dumphex(inter_addr->phys_addr + dump_index, (sizeof(inter_addr->phys_addr) - dump_index),
1339+
&one_addr[0]);
13391340
}
13401341

13411342
if (!one_addr.empty()) {
@@ -2191,8 +2192,8 @@ void node::remove_ping_timer(timer_desc_ls<std::weak_ptr<endpoint> >::type::iter
21912192
}
21922193

21932194
void node::init_hash_code() {
2194-
util::hash::sha sha256;
2195-
sha256.init(util::hash::sha::EN_ALGORITHM_SHA256);
2195+
atfw::util::hash::sha sha256;
2196+
sha256.init(atfw::util::hash::sha::EN_ALGORITHM_SHA256);
21962197

21972198
// hash all interface
21982199
{
@@ -2214,8 +2215,8 @@ void node::init_hash_code() {
22142215
}
22152216
if (dump_index < sizeof(inter_addr->phys_addr)) {
22162217
one_addr.resize((sizeof(inter_addr->phys_addr) - dump_index) * 2);
2217-
util::string::dumphex(inter_addr->phys_addr + dump_index, (sizeof(inter_addr->phys_addr) - dump_index),
2218-
&one_addr[0]);
2218+
atfw::util::string::dumphex(inter_addr->phys_addr + dump_index, (sizeof(inter_addr->phys_addr) - dump_index),
2219+
&one_addr[0]);
22192220
}
22202221

22212222
if (!one_addr.empty()) {

src/channel_io_stream.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747

4848
#define ATBUS_MACRO_TLS_MERGE_BUFFER_LEN (ATBUS_MACRO_MSG_LIMIT - ATBUS_MACRO_DATA_ALIGN_SIZE - sizeof(uv_write_t))
4949

50-
#if !(defined(THREAD_TLS_USE_PTHREAD) && THREAD_TLS_USE_PTHREAD) && defined(UTIL_CONFIG_THREAD_LOCAL)
50+
#if !(defined(ATFRAMEWORK_UTILS_THREAD_TLS_USE_PTHREAD) && ATFRAMEWORK_UTILS_THREAD_TLS_USE_PTHREAD) && \
51+
defined(UTIL_CONFIG_THREAD_LOCAL)
5152
namespace atbus {
5253
namespace channel {
5354
namespace detail {
@@ -564,8 +565,8 @@ static void io_stream_on_recv_read_fn(uv_stream_t *stream, ssize_t nread, const
564565
// 如果读取vint成功,判定是否有小数据包。并对小数据包直接回调
565566
if (buff_left_len >= sizeof(uint32_t) + vint_len + msg_len) {
566567
channel->error_code = 0;
567-
uint32_t check_hash =
568-
util::hash::murmur_hash3_x86_32(buff_start + sizeof(uint32_t) + vint_len, static_cast<int>(msg_len), 0);
568+
uint32_t check_hash = atfw::util::hash::murmur_hash3_x86_32(buff_start + sizeof(uint32_t) + vint_len,
569+
static_cast<int>(msg_len), 0);
569570
uint32_t expect_hash;
570571
memcpy(&expect_hash, buff_start, sizeof(uint32_t));
571572
int errcode = EN_ATBUS_ERR_SUCCESS;
@@ -635,8 +636,8 @@ static void io_stream_on_recv_read_fn(uv_stream_t *stream, ssize_t nread, const
635636
data = ::atbus::detail::fn::buffer_prev(data, sread);
636637

637638
// 32位Hash校验和
638-
uint32_t check_hash = util::hash::murmur_hash3_x86_32(reinterpret_cast<char *>(data) + sizeof(uint32_t),
639-
static_cast<int>(sread - sizeof(uint32_t)), 0);
639+
uint32_t check_hash = atfw::util::hash::murmur_hash3_x86_32(reinterpret_cast<char *>(data) + sizeof(uint32_t),
640+
static_cast<int>(sread - sizeof(uint32_t)), 0);
640641
uint32_t expect_hash;
641642
memcpy(&expect_hash, data, sizeof(uint32_t));
642643
size_t msg_len = sread - sizeof(uint32_t); // - hash32 header
@@ -1099,7 +1100,7 @@ static void io_stream_pipe_connection_cb(uv_stream_t *req, int status) {
10991100
io_stream_pipe_setup(channel, pipe_conn);
11001101
io_stream_pipe_init(channel, conn.get(), pipe_conn);
11011102

1102-
char pipe_path[util::file_system::MAX_PATH_LEN];
1103+
char pipe_path[atfw::util::file_system::MAX_PATH_LEN];
11031104
size_t path_len = sizeof(pipe_path);
11041105
uv_pipe_getpeername(pipe_conn, pipe_path, &path_len);
11051106
if (0 == path_len || 0 == pipe_path[0]) {
@@ -1299,9 +1300,9 @@ int io_stream_listen(io_stream_channel *channel, const channel_address_t &addr,
12991300
// try to mkdir for basedir
13001301
{
13011302
std::string dirname;
1302-
if (util::file_system::dirname(addr.host.c_str(), addr.host.size(), dirname)) {
1303-
if (!util::file_system::is_exist(dirname.c_str())) {
1304-
util::file_system::mkdir(dirname.c_str(), true);
1303+
if (atfw::util::file_system::dirname(addr.host.c_str(), addr.host.size(), dirname)) {
1304+
if (!atfw::util::file_system::is_exist(dirname.c_str())) {
1305+
atfw::util::file_system::mkdir(dirname.c_str(), true);
13051306
}
13061307
}
13071308
}
@@ -1952,7 +1953,8 @@ int io_stream_send(io_stream_connection *connection, const void *buf, size_t len
19521953
buff_start += sizeof(uv_write_t);
19531954

19541955
// 32bits hash
1955-
uint32_t hash32 = util::hash::murmur_hash3_x86_32(reinterpret_cast<const char *>(buf), static_cast<int>(len), 0);
1956+
uint32_t hash32 =
1957+
atfw::util::hash::murmur_hash3_x86_32(reinterpret_cast<const char *>(buf), static_cast<int>(len), 0);
19561958
memcpy(buff_start, &hash32, sizeof(uint32_t));
19571959

19581960
// vint

0 commit comments

Comments
 (0)