From b029ff78a59bfe8af4e66f844644a776f7678eef Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期一, 21 十二月 2020 17:49:51 +0800
Subject: [PATCH] bus 加停止功能
---
src/socket/net_mod_server_socket.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/socket/net_mod_server_socket.c b/src/socket/net_mod_server_socket.c
index a021aa8..0de0523 100644
--- a/src/socket/net_mod_server_socket.c
+++ b/src/socket/net_mod_server_socket.c
@@ -3,6 +3,7 @@
#include "socket_io.h"
#include "net_mod_socket_io.h"
#include "net_mod_socket.h"
+#include "key_def.h"
static Logger * logger = LoggerFactory::getLogger();
@@ -139,8 +140,8 @@
request_head = NetModSocket::decode_request_head(request_head_bs);
-printf("server received request from host = %s:%d, key = %d, timeout=%d,\n",
- request_head.host, request_head.port , request_head.key, request_head.timeout);
+// printf("server received request from host = %s:%d, key = %d, timeout=%d,\n",
+// request_head.host, request_head.port , request_head.key, request_head.timeout);
if(request_head.content_length > max_buf) {
@@ -214,6 +215,7 @@
} else if(request_head.mod == BUS) {
+
if(request_head.topic_length > max_topic_buf) {
if( (topic_buf = realloc(topic_buf, request_head.topic_length)) == NULL ) {
LoggerFactory::getLogger()->error(errno, "NetModServerSocket::process_client realloc topic_buf");
@@ -226,23 +228,22 @@
if (rio_readn(connfd, topic_buf, request_head.topic_length) != request_head.topic_length ) {
return -1;
}
-LoggerFactory::getLogger()->debug("====server pub %s===\n", buf);
+// LoggerFactory::getLogger()->debug("====server pub %s===\n", buf);
memcpy(response_head.host, request_head.host, NI_MAXHOST);
response_head.port = request_head.port;
- response_head.key = request_head.key;
+ // response_head.key = request_head.key;
if(request_head.timeout > 0) {
timeout.tv_sec = request_head.timeout / 1000;
timeout.tv_nsec = (request_head.timeout - timeout.tv_sec * 1000) * 10e6;
- ret = shmModSocket.pub_timeout((char*)topic_buf, request_head.topic_length, buf, request_head.content_length, request_head.key, &timeout);
+ ret = shmModSocket.pub_timeout((char*)topic_buf, request_head.topic_length, buf, request_head.content_length, BUS_KEY, &timeout);
}
else if(request_head.timeout == 0) {
- ret = shmModSocket.pub_nowait((char*)topic_buf, request_head.topic_length, buf, request_head.content_length, request_head.key);
+ ret = shmModSocket.pub_nowait((char*)topic_buf, request_head.topic_length, buf, request_head.content_length, BUS_KEY);
}
else if(request_head.timeout == -1) {
- ret = shmModSocket.pub((char*)topic_buf, request_head.topic_length, buf, request_head.content_length, request_head.key);
+ ret = shmModSocket.pub((char*)topic_buf, request_head.topic_length, buf, request_head.content_length, BUS_KEY);
}
-
response_head.code = ret;
response_head.content_length = 0;
if( rio_writen(connfd, NetModSocket::encode_response_head(response_head), NET_MODE_RESPONSE_HEAD_LENGTH) != NET_MODE_RESPONSE_HEAD_LENGTH )
--
Gitblit v1.8.0