fujuntang
2021-12-07 22cd4140502e67d32967160bee56375eaa285011
Fix the service query fail issue.
5个文件已修改
39 ■■■■ 已修改文件
src/bh_api.cpp 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/net/net_mod_socket.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/net/net_mod_socket.h 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/net/net_mod_socket_wrapper.cpp 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/net/net_mod_socket_wrapper.h 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/bh_api.cpp
@@ -1244,7 +1244,8 @@
  char data_buf[MAX_STR_LEN] = { 0x00 };
  char buf_temp[MAX_STR_LEN] = { 0x00 };
  char *topics_buf = NULL;
  hashtable_t *hashtable = mm_get_hashtable();
#if defined(PRO_DE_SERIALIZE)
  struct _BHAddress
    {
@@ -1301,14 +1302,19 @@
#else 
  strncpy(buf_temp, (char *)request, (sizeof(buf_temp) - 1) > strlen((char *)request) ? strlen((char *)request) : (sizeof(buf_temp) - 1));
#endif 
  str = buf_temp;
  val = net_mod_socket_buf_data_get(gNetmod_socket, str);
  if(val > 0) {
  if ((val > 0) && (hashtable_get(hashtable, val) != NULL)) {
    rv = 0;
  } else {
    if ((val > 0) && (hashtable_get(hashtable, val) == NULL)) {
      net_mod_socket_buf_data_del(gNetmod_socket, str);
    }
    rv = net_mod_socket_reg(gNetmod_socket, buf_temp, strlen(buf_temp), &buf, &size, timeout_ms, PROC_QUE_STCS);
    if (rv == 0) {
@@ -1420,7 +1426,8 @@
  char *errString = NULL;
  char buf_temp[MAX_STR_LEN] = { 0x00 };
  char *topics_buf = NULL;
  hashtable_t *hashtable = mm_get_hashtable();
  struct _RequestReply
  {
    std::string proc_id;
@@ -1487,10 +1494,13 @@
 
  str = buf_temp;
  val = net_mod_socket_buf_data_get(gNetmod_socket, str);
  if(val > 0) {
  if ((val > 0) && (hashtable_get(hashtable, val) != NULL)) {
    rv = 0;
  } else {
    if ((val > 0) && (hashtable_get(hashtable, val) == NULL)) {
      net_mod_socket_buf_data_del(gNetmod_socket, str);
    }
    rv = net_mod_socket_reg(gNetmod_socket, buf_temp, strlen(buf_temp), &buf, &size, timeout_ms, PROC_QUE_STCS);
    if (rv == 0) {
    
src/net/net_mod_socket.cpp
@@ -360,6 +360,10 @@
  return val;
}
void NetModSocket::buf_data_del(std::string str) {
  recvbuf.erase(str);
}
void NetModSocket::free_recv_msg_arr(net_mod_recv_msg_t * arr, size_t size) {
  for(int i =0; i< size; i++) {
src/net/net_mod_socket.h
@@ -250,6 +250,7 @@
 
  void buf_data_set(std::string str, int val);
  int buf_data_get(std::string str);
  void buf_data_del(std::string str);
};
 
#endif
#endif
src/net/net_mod_socket_wrapper.cpp
@@ -133,6 +133,11 @@
  return sockt->buf_data_get(str);
}
void net_mod_socket_buf_data_del(void * _socket, std::string str) {
  NetModSocket *sockt = (NetModSocket *)_socket;
  sockt->buf_data_del(str);
}
/**
 * 如果建立连接的节点没有接受到消息等待timeout的时间后返回
 * @timeout 等待时间,单位是千分之一秒
src/net/net_mod_socket_wrapper.h
@@ -134,6 +134,7 @@
int net_mod_socket_svr_get(void * _socket);
void net_mod_socket_buf_data_set(void * _socket, std::string str, int val);
int net_mod_socket_buf_data_get(void * _socket, std::string str);
void net_mod_socket_buf_data_del(void * _socket, std::string str);
/**
 * @brief 跨机器发送消息并接受返回的应答消息,直到发送完成才返回
@@ -403,4 +404,4 @@
}
#endif
#endif
#endif