lichao
2021-05-20 4ad4f24f18cf7d0af22ca885baebc6a3eb37e7d0
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_;
}
}
int NodeTimeoutSec() { return 60; }