From 68c7bef33e74f23aa0136ccd6f7faa654d671ebc Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期五, 21 五月 2021 09:23:01 +0800 Subject: [PATCH] center publish notify; fix topic partial match. --- src/defs.cpp | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/defs.cpp b/src/defs.cpp index 6e7a5fd..2715911 100644 --- a/src/defs.cpp +++ b/src/defs.cpp @@ -18,7 +18,7 @@ #include "defs.h" #include "msg.h" #include "shm_msg_queue.h" -#include "socket.h" +#include "shm_socket.h" #include <boost/uuid/random_generator.hpp> #include <boost/uuid/string_generator.hpp> #include <boost/uuid/uuid.hpp> @@ -104,7 +104,7 @@ // which node might crash inside and cause deadlock. bool CenterInit(bhome_shm::SharedMemory &shm) { - Mutex *mutex = shm.Create<Mutex>("shm_center_lock"); + Mutex *mutex = shm.FindOrCreate<Mutex>("shm_center_lock"); if (!mutex || !mutex->try_lock()) { return false; } @@ -132,7 +132,6 @@ InitMQ(info.mq_sender_, NextId()); InitMQ(info.mq_center_, NextId()); InitMQ(info.mq_bus_, NextId()); - InitMQ(info.mq_init_, NextId()); pmeta->tag_ = kCenterInfoTag; return true; @@ -144,7 +143,14 @@ const MQInfo &BHGlobalSenderAddress() { return GetCenterInfo(BHomeShm())->mq_sender_; } const MQInfo &BHTopicCenterAddress() { return GetCenterInfo(BHomeShm())->mq_center_; } const MQInfo &BHTopicBusAddress() { return GetCenterInfo(BHomeShm())->mq_bus_; } -const MQInfo &BHCenterReplyAddress() { return GetCenterInfo(BHomeShm())->mq_init_; } +bool BHNodeInit(const int64_t request, int64_t &reply) +{ + return GetCenterInfo(BHomeShm())->init_rr_.ClientRequest(request, reply); +} +void BHCenterHandleInit(std::function<int64_t(const int64_t)> const &onReq) +{ + GetCenterInfo(BHomeShm())->init_rr_.ServerProcess(onReq); +} int64_t CalcAllocIndex(int64_t size) { @@ -181,4 +187,6 @@ { ec = LastErrorStore().ec_; msg = LastErrorStore().msg_; -} \ No newline at end of file +} + +int NodeTimeoutSec() { return 60; } \ No newline at end of file -- Gitblit v1.8.0