From 26ed48c4e616014ee760fd13d13dbdc8539c34e3 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期二, 22 十二月 2020 19:21:55 +0800 Subject: [PATCH] 解决sendandrecv发送到一个不存在key的情况 --- src/socket/net_mod_socket_wrapper.c | 64 +++++++++++++++++-------------- 1 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/socket/net_mod_socket_wrapper.c b/src/socket/net_mod_socket_wrapper.c index d597644..61373dd 100644 --- a/src/socket/net_mod_socket_wrapper.c +++ b/src/socket/net_mod_socket_wrapper.c @@ -7,6 +7,7 @@ * 鍒涘缓 */ void * net_mod_socket_open() { + printf("=====net_mod_socket_open\n"); net_mod_socket_t *sockt = (net_mod_socket_t *)malloc(sizeof(net_mod_socket_t)); sockt->sockt = new NetModSocket; return (void *)sockt; @@ -16,6 +17,7 @@ * 鍏抽棴 */ void net_mod_socket_close(void *_socket) { + printf("====net_mod_socket_close\n"); net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; delete sockt->sockt; free(sockt); @@ -125,25 +127,18 @@ net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; return sockt->sockt->pub(node_arr, node_arr_len, topic, topic_size, content, content_size); } -int net_mod_socket_pub_timeout(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size, int timeout){ - return 0; -} -int net_mod_socket_pub_nowait(void *_sockt, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size){ - return 0; -} - - - - -/** - * 鍚姩bus - * - * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 -*/ -int net_mod_socket_start_bus(void * _socket) { +int net_mod_socket_pub_timeout(void *_socket, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size, int msec){ net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->start_bus(); + return sockt->sockt->pub_timeout(node_arr, node_arr_len, topic, topic_size, content, content_size, msec); } +int net_mod_socket_pub_nowait(void *_socket, net_node_t *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size){ + net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; + return sockt->sockt->pub_nowait(node_arr, node_arr_len, topic, topic_size, content, content_size); +} + + + + /** * 璁㈤槄鎸囧畾涓婚 @@ -151,18 +146,18 @@ * @size 涓婚闀垮害 * @port 鎬荤嚎绔彛 */ -int net_mod_socket_sub(void * _socket, void *topic, int size, int port) { +int net_mod_socket_sub(void * _socket, void *topic, int size) { net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sub((char *)topic, size, port); + return sockt->sockt->sub((char *)topic, size, BUS_KEY); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int net_mod_socket_sub_timeout(void * _socket, void *topic, int size, int port, int sec, int nsec){ +int net_mod_socket_sub_timeout(void * _socket, void *topic, int size, int sec, int nsec){ net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sub_timeout((char *)topic, size, port, sec, nsec); + return sockt->sockt->sub_timeout((char *)topic, size, BUS_KEY, sec, nsec); } -int net_mod_socket_sub_nowait(void * _socket, void *topic, int size, int port){ +int net_mod_socket_sub_nowait(void * _socket, void *topic, int size){ net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->sub_nowait((char *)topic, size, port); + return sockt->sockt->sub_nowait((char *)topic, size, BUS_KEY); } @@ -172,18 +167,18 @@ * @size 涓婚闀垮害 * @port 鎬荤嚎绔彛 */ -int net_mod_socket_desub(void * _socket, void *topic, int size, int port) { +int net_mod_socket_desub(void * _socket, void *topic, int size) { net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->desub((char *)topic, size, port); + return sockt->sockt->desub((char *)topic, size, BUS_KEY); } // 瓒呮椂杩斿洖銆� @sec 绉� 锛� @nsec 绾崇 -int net_mod_socket_desub_timeout(void * _socket, void *topic, int size, int port, int sec, int nsec) { +int net_mod_socket_desub_timeout(void * _socket, void *topic, int size, int sec, int nsec) { net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->desub_timeout((char *)topic, size, port, sec, nsec); + return sockt->sockt->desub_timeout((char *)topic, size, BUS_KEY, sec, nsec); } -int net_mod_socket_desub_nowait(void * _socket, void *topic, int size, int port){ +int net_mod_socket_desub_nowait(void * _socket, void *topic, int size){ net_mod_socket_t *sockt = (net_mod_socket_t *)_socket; - return sockt->sockt->desub_nowait((char *)topic, size, port); + return sockt->sockt->desub_nowait((char *)topic, size, BUS_KEY); } @@ -215,3 +210,14 @@ return NetModSocket::free_recv_msg_arr(arr, len); } + + + +int shm_mod_socket_remove_keys(int keys[], int length){ + return ShmModSocket::remove_keys(keys, length); +} + +int shm_mod_socket_remove_key(int key){ + int keys[] = {key}; + return ShmModSocket::remove_keys(keys, 1); +} -- Gitblit v1.8.0