wangzhengquan
2021-01-14 a1b6b9ae58c85ec1801935676c9dd76682a313b1
CMake
1个文件已删除
1个文件已添加
8个文件已修改
108 ■■■■■ 已修改文件
build.sh 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/BusConfig.h.in 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/CMakeLists.txt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/bus_config.h.in 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/logger_factory.cpp 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/logger_factory.h 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/queue/lock_free_queue.h 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/shm_mod_socket.cpp 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/shm_mod_socket.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/socket/shm_socket.cpp 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
build.sh
@@ -4,11 +4,23 @@
# rm -rf build/*
cd build
 
BUILD_TYPE="Debug"
case ${1} in
  "release")
  BUILD_TYPE="Release"
  ;;
  *)
     BUILD_TYPE="Debug"
  ;;
esac
# -DCMAKE_BUILD_TYPE=Debug  | Release
# -DBUILD_SHARED_LIBS=ON
# -DCMAKE_INSTALL_PREFIX=$(pwd/../dest)
# -DQCA_MAN_INSTALL_DIR:PATH=/usr/share/man 
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/../dest" -DCMAKE_BUILD_TYPE=Debug -DSUPPORT_RDMA=OFF ..
cmake -DCMAKE_INSTALL_PREFIX="$(pwd)/../dest" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_RDMA=OFF ..
cmake --build .
src/BusConfig.h.in
File was deleted
src/CMakeLists.txt
@@ -5,7 +5,7 @@
# configure a header file to pass some of the CMake settings
# to the source code
configure_file(BusConfig.h.in BusConfig.h)
configure_file(bus_config.h.in bus_config.h)
add_library(shm_queue 
        logger_factory.cpp
@@ -21,7 +21,6 @@
        socket/net_mod_socket_io.cpp
        socket/net_mod_server_socket.cpp
        bus_error.cpp
        queue/shm_queue_wrapper.cpp
        shm/shm_mm_wrapper.cpp
        shm/mm.cpp
        shm/hashtable.cpp
@@ -34,7 +33,7 @@
                           )
target_include_directories(shm_queue PUBLIC
                                                     ${PROJECT_BINARY_DIR}
                                                     ${PROJECT_BINARY_DIR}/src
                           ${CMAKE_CURRENT_SOURCE_DIR}
                           ${CMAKE_CURRENT_SOURCE_DIR}/shm
                           ${CMAKE_CURRENT_SOURCE_DIR}/queue
src/bus_config.h.in
New file
@@ -0,0 +1,12 @@
// the configured options and settings for Bus
#ifndef __BUS_CONFIG_H__
#define __BUS_CONFIG_H__
#define B_BUS_VERSION_MAJOR @B_BUS_VERSION_MAJOR@
#define B_BUS_VERSION_MINOR @B_BUS_VERSION_MINOR@
#cmakedefine SUPPORT_RDMA
#define BUILD_@CMAKE_BUILD_TYPE@
#endif
src/logger_factory.cpp
@@ -1,3 +1,22 @@
#include "logger_factory.h"
Logger * LoggerFactory::logger = NULL;
Logger * LoggerFactory::logger = NULL;
Logger* LoggerFactory::getLogger() {
//ERROR ALL DEBUG INFO WARN
    if(logger != NULL)
        return logger;
    LoggerConfig config;
#ifdef BUILD_Debug
    config.level = Logger::DEBUG;
#else
    config.level = Logger::INFO;
#endif
    config.logFile =  "bhome_bus.log";
    config.console = 1;
    logger = new Logger(config);
    return logger;
}
src/logger_factory.h
@@ -1,6 +1,7 @@
#ifndef __LOGGER_FACTORY_H__
#define __LOGGER_FACTORY_H__
#include "logger.h"
#include "bus_config.h"
class LoggerFactory {
private:
@@ -8,18 +9,7 @@
public:
    static Logger* getLogger() {
//ERROR ALL DEBUG INFO WARN
        if(logger != NULL)
            return logger;
        LoggerConfig config;
        config.level = Logger::DEBUG;
        config.logFile =  "softbus.log";
        config.console = 1;
        logger = new Logger(config);
        return logger;
    }
    static Logger* getLogger();
};
#endif
src/queue/lock_free_queue.h
@@ -300,7 +300,7 @@
int LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::pop(ELEM_T &a_data)
{
// LoggerFactory::getLogger()->debug("==================LockFreeQueue pop before\n");
 // LoggerFactory::getLogger()->debug("==================LockFreeQueue pop before\n");
    if (sem_wait(&items) == -1) {
        LoggerFactory::getLogger()->error(errno, "LockFreeQueue pop");
        return errno;
@@ -345,7 +345,7 @@
{
// LoggerFactory::getLogger()->debug("=================ts sec = %d, nsec = %ld \n", ts->tv_sec,  ts->tv_nsec );
    // struct timespec timeout_tmp = {1, 0};
    LoggerFactory::getLogger()->debug("==================LockFreeQueue pop_timeout before\n");
    struct timespec timeout = PXSemUtil::calc_sem_timeout(ts);
// LoggerFactory::getLogger()->debug("================== timeout before sec = %d, nsec = %ld \n", timeout.tv_sec,  timeout.tv_nsec );
src/socket/shm_mod_socket.cpp
@@ -9,7 +9,6 @@
}
ShmModSocket::ShmModSocket() {
    mod = (socket_mod_t)0;
    shm_socket = shm_open_socket(SHM_SOCKET_DGRAM);
    bus_set = new std::set<int>;
}
@@ -54,20 +53,7 @@
int ShmModSocket::sendto_nowait( const void *buf, const int size, const int key){
    return shm_sendto(shm_socket, buf, size, key, NULL, (int)SHM_MSG_NOWAIT);
}
inline int ShmModSocket::_recvfrom_(void **buf, int *size, int *key,  struct timespec *timeout, int flags) {
    if(mod == BUS) {
        logger->error("Can not use method recvfrom in a Bus");
        exit(1);
    }
// printf("dgram_mod_recvfrom  before\n");
    int rv = shm_recvfrom(shm_socket, buf, size, key, timeout, flags);
// printf("dgram_mod_recvfrom  after\n");
    return rv;
}
/**
 * 接收信息
@@ -75,7 +61,7 @@
 * @return 0 成功, 其他值 失败的错误码
*/
int ShmModSocket::recvfrom(void **buf, int *size, int *key) {
    int rv =  _recvfrom_( buf, size, key, NULL, 0);
    int rv =  shm_recvfrom(shm_socket, buf, size, key, NULL, 0);
    // logger->error(rv, "ShmModSocket::recvfrom failed!");
  return rv;
}
@@ -83,12 +69,12 @@
// 接受信息超时返回。 @sec 秒 , @nsec 纳秒
int ShmModSocket::recvfrom_timeout( void **buf, int *size, int *key, struct timespec *timeout) {
    int rv =  _recvfrom_(buf, size, key, timeout, 0);
    int rv =  shm_recvfrom(shm_socket, buf, size, key, timeout, 0);
     return rv;
}
int ShmModSocket::recvfrom_nowait( void **buf, int *size, int *key){
    int rv =  _recvfrom_(buf, size, key, NULL, (int)SHM_MSG_NOWAIT);
    int rv =  shm_recvfrom(shm_socket, buf, size, key, NULL, (int)SHM_MSG_NOWAIT);
    // logger->error(rv, "ShmModSocket::recvfrom_nowait failed!");
  return rv;
}
src/socket/shm_mod_socket.h
@@ -26,12 +26,10 @@
friend class BusServerSocket;
private:
    shm_socket_t *shm_socket;
  socket_mod_t mod;
  
    std::set<int> *bus_set;
private:
    inline int _recvfrom_(void **buf, int *size, int *key,  struct timespec *timeout, int flags);
     
    int _sub_( char *topic, int size, int key, struct timespec *timeout, int flags);
    int _pub_( char *topic, int topic_size, void *content, int content_size, int key, struct timespec *timeout, int flags);
src/socket/shm_socket.cpp
@@ -52,7 +52,7 @@
  logger->debug("shm_open_socket\n");
  shm_socket_t *socket = (shm_socket_t *)calloc(1, sizeof(shm_socket_t));
  socket->socket_type = socket_type;
  socket->key = -1;
  socket->key = 0;
  socket->force_bind = false;
  socket->dispatch_thread = 0;
  socket->status = SHM_CONN_CLOSED;
@@ -127,7 +127,7 @@
  int key;
  hashtable_t *hashtable = mm_get_hashtable();
  if (socket->key == -1) {
  if (socket->key == 0) {
    key = hashtable_alloc_key(hashtable);
    socket->key = key;
  } else {
@@ -220,7 +220,7 @@
    return -1;
  }
  if (socket->key == -1) {
  if (socket->key == 0) {
    socket->key = hashtable_alloc_key(hashtable);
  } else {
    if(!_shm_socket_check_key(socket)) {
@@ -333,7 +333,7 @@
    err_exit(s, "shm_sendto : pthread_mutex_lock");
  if (socket->queue == NULL) {
    if (socket->key == -1) {
    if (socket->key == 0) {
      socket->key = hashtable_alloc_key(hashtable);
    } else {
@@ -415,7 +415,7 @@
    err_exit(s, "shm_recvfrom : pthread_mutex_lock");
 
  if (socket->queue == NULL) {
    if (socket->key == -1) {
    if (socket->key == 0) {
      socket->key = hashtable_alloc_key(hashtable);
    } else {