From 4c73fd7179e92bee9cccb65e46823b00f568acb3 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期五, 22 一月 2021 16:57:34 +0800 Subject: [PATCH] tmp --- src/socket/shm_socket.cpp | 24 ++++++++---------------- 1 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/socket/shm_socket.cpp b/src/socket/shm_socket.cpp index 534202d..e370c72 100644 --- a/src/socket/shm_socket.cpp +++ b/src/socket/shm_socket.cpp @@ -373,9 +373,9 @@ memcpy(dest.buf, buf, size); - if(flags & SHM_MSG_NOWAIT != 0) { + if( (flags & BUS_NOWAIT_FLAG) == BUS_NOWAIT_FLAG) { rv = remoteQueue->push_nowait(dest); - } else if(timeout != NULL) { + } else if((flags & BUS_TIMEOUT_FLAG) == BUS_TIMEOUT_FLAG && timeout != NULL) { rv = remoteQueue->push_timeout(dest, timeout); } else { rv = remoteQueue->push(dest); @@ -383,10 +383,8 @@ if (rv == 0) { // printf("shm_sendto push after\n"); - delete remoteQueue; return 0; } else { - delete remoteQueue; mm_free(dest.buf); if(rv > EBUS_BASE) { // bus_errno = EBUS_TIMEOUT; @@ -395,8 +393,6 @@ logger->error(rv, "sendto key %d failed", key); } return rv; - - } } @@ -435,9 +431,9 @@ shm_msg_t src; - if(flags & SHM_MSG_NOWAIT != 0) { + if((flags & BUS_NOWAIT_FLAG) == BUS_NOWAIT_FLAG) { rv = socket->queue->pop_nowait(src); - } else if(timeout != NULL) { + } else if((flags & BUS_TIMEOUT_FLAG) == BUS_TIMEOUT_FLAG && timeout != NULL) { rv = socket->queue->pop_timeout(src, timeout); // printf("0 shm_recvfrom====%d\n", rv); } else { @@ -651,7 +647,7 @@ switch (src.type) { case SHM_SOCKET_OPEN: - socket->acceptQueue->push_timeout(src, &timeout); + socket->acceptQueue->push(src, &timeout, BUS_TIMEOUT_FLAG); break; case SHM_SOCKET_CLOSE: _server_close_conn_to_client(socket, src.key); @@ -662,7 +658,7 @@ if (iter != socket->clientSocketMap->end()) { client_socket = iter->second; // print_msg("_server_run_msg_rev push before", src); - client_socket->messageQueue->push_timeout(src, &timeout); + client_socket->messageQueue->push(src, &timeout, BUS_TIMEOUT_FLAG); // print_msg("_server_run_msg_rev push after", src); } @@ -697,7 +693,7 @@ _client_close_conn_to_server(socket); break; case SHM_COMMON_MSG: - socket->messageQueue->push_timeout(src, &timeout); + socket->messageQueue->push(src, &timeout, BUS_TIMEOUT_FLAG); break; default: logger->error( "shm_socket._client_run_msg_rev: undefined message type."); @@ -725,10 +721,7 @@ socket->queue = NULL; } - if (socket->remoteQueue != NULL) { - delete socket->remoteQueue; - socket->remoteQueue = NULL; - } + if (socket->messageQueue != NULL) { delete socket->messageQueue; @@ -747,7 +740,6 @@ client_socket = iter->second; client_socket->remoteQueue->push_timeout(close_msg, &timeout); - delete client_socket->remoteQueue; client_socket->remoteQueue = NULL; delete client_socket->messageQueue; -- Gitblit v1.8.0