wangzhengquan
2021-02-03 758438289fc45829a8f6cef1b42afed0a1a8cb60
src/socket/shm_mod_socket.cpp
@@ -89,6 +89,19 @@
  logger->debug("ShmModSocket::sendandrecv : sendandrecv to %d failed %s",  send_key, bus_strerror(rv));
   return rv;
}
int ShmModSocket::recvandsend(void **recvbuf, int *recvsize, int *key, recv_callback_fn callback,
                    const struct timespec *timeout , int flag ) {
  int rv = shm_recvandsend(shm_socket, recvbuf, recvsize, key, callback, timeout, flag);
  if(rv == 0) {
    logger->debug("ShmModSocket::shm_recvandsend: success. key = %d\n", *key);
    return 0;
  }
  logger->debug("ShmModSocket::shm_recvandsend :  failed. %s", bus_strerror(rv));
  return rv;
}
 
// // 超时返回。 @sec 秒 , @nsec 纳秒
// int ShmModSocket::sendandrecv_unsafe(const void *send_buf, const int send_size, const int send_key, 
@@ -102,7 +115,7 @@
 * @size 主题长度
 * @key 总线端口
 */
int  ShmModSocket::sub(char *topic, int topic_size, int key,
int  ShmModSocket::sub(const char *topic, int topic_size, int key,
   const struct timespec *timeout, int flags) {
   int ret;
   bus_head_t head = {};
@@ -133,7 +146,7 @@
 * @size 主题长度
 * @key 总线端口
 */
int  ShmModSocket::desub(char *topic, int topic_size, int key, const struct timespec *timeout, int flags) {
int  ShmModSocket::desub(const char *topic, int topic_size, int key, const struct timespec *timeout, int flags) {
   // char buf[8192];
   int ret;
   if(topic == NULL) {
@@ -171,7 +184,7 @@
 * @content 主题内容
 * @key 总线端口
 */
int  ShmModSocket::pub(char *topic, int topic_size, void *content, int content_size, int key, const struct timespec *timeout, int flags) {
int  ShmModSocket::pub(const char *topic, int topic_size, const void *content, int content_size, int key, const struct timespec *timeout, int flags) {
   int ret;
   bus_head_t head = {};
   memcpy(head.action, "pub", sizeof(head.action));
@@ -204,7 +217,7 @@
// =============================================================================
int ShmModSocket::get_bus_sendbuf(bus_head_t &request_head, 
  void *topic_buf, int topic_size, void *content_buf, int content_size, void **retbuf) {
 const void *topic_buf, int topic_size, const void *content_buf, int content_size, void **retbuf) {
 
  int buf_size;
  char *buf;