From 14c345b38d57fd814f217eb8465963a08ca79f7e Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期五, 05 二月 2021 17:41:09 +0800 Subject: [PATCH] update --- src/net/net_mod_socket.cpp | 46 ++++++++++++++++++++++++++++++---------------- 1 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/net/net_mod_socket.cpp b/src/net/net_mod_socket.cpp index 3668b14..ef817f0 100644 --- a/src/net/net_mod_socket.cpp +++ b/src/net/net_mod_socket.cpp @@ -19,35 +19,39 @@ if (Signal(SIGPIPE, SIG_IGN) == SIG_ERR) logger->error(errno, "NetModSocket::NetModSocket signal"); - gpool = new NetConnPool(); + // gpool = new NetConnPool(); - pthread_mutexattr_t mtxAttr; - s = pthread_mutexattr_init(&mtxAttr); - if (s != 0) - err_exit(s, "pthread_mutexattr_init"); - s = pthread_mutexattr_settype(&mtxAttr, PTHREAD_MUTEX_ERRORCHECK); - if (s != 0) - err_exit(s, "pthread_mutexattr_settype"); - s = pthread_mutex_init(&sendMutex, &mtxAttr); - if (s != 0) - err_exit(s, "pthread_mutex_init"); + // pthread_mutexattr_t mtxAttr; + // s = pthread_mutexattr_init(&mtxAttr); + // if (s != 0) + // err_exit(s, "pthread_mutexattr_init"); + // s = pthread_mutexattr_settype(&mtxAttr, PTHREAD_MUTEX_ERRORCHECK); + // if (s != 0) + // err_exit(s, "pthread_mutexattr_settype"); + // s = pthread_mutex_init(&sendMutex, &mtxAttr); + // if (s != 0) + // err_exit(s, "pthread_mutex_init"); - s = pthread_mutexattr_destroy(&mtxAttr); - if (s != 0) - err_exit(s, "pthread_mutexattr_destroy"); + // s = pthread_mutexattr_destroy(&mtxAttr); + // if (s != 0) + // err_exit(s, "pthread_mutexattr_destroy"); } NetModSocket::~NetModSocket() { int s; - delete gpool; - s = pthread_mutex_destroy(&sendMutex); + // delete gpool; + // s = pthread_mutex_destroy(&sendMutex); if(s != 0) { err_exit(s, "shm_close_socket"); } } + +int NetModSocket::stop() { + return shmModSocket.stop(); +} /** * 缁戝畾绔彛鍒皊ocket, 濡傛灉涓嶇粦瀹氬垯绯荤粺鑷姩鍒嗛厤涓�涓� @@ -139,6 +143,8 @@ NetConnPool* NetModSocket::_get_pool() { return _get_threadlocal_pool(); } + + int NetModSocket::_sendandrecv_(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, @@ -495,6 +501,14 @@ return shmModSocket.recvfrom(buf, size, key, NULL, BUS_NOWAIT_FLAG); } + +int NetModSocket::recvandsend(recvandsend_callback_fn callback, + const struct timespec *timeout , int flag, void * user_data ) { + + return shmModSocket.recvandsend(callback, timeout, flag, user_data); +} + + /** * 鍙戦�佽姹備俊鎭苟绛夊緟鎺ユ敹搴旂瓟 * @key 鍙戦�佺粰璋� -- Gitblit v1.8.0