Skip to content

Commit 67b8fb0

Browse files
committed
fix(network):1.10.12, 解决TcpConnection在发生error时,没有当作连接断开处理的问题
1 parent 00ca56b commit 67b8fb0

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

modules/network/tcp_acceptor.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <tbox/base/log.h>
2828
#include <tbox/base/assert.h>
2929
#include <tbox/base/wrapped_recorder.h>
30+
#include <tbox/util/fs.h>
3031

3132
#include "tcp_connection.h"
3233

@@ -134,9 +135,7 @@ void TcpAcceptor::cleanup()
134135
//! 对于Unix Domain的Socket在退出的时候要删除对应的socket文件
135136
if (bind_addr_.type() == SockAddr::Type::kLocal) {
136137
auto socket_file = bind_addr_.toString();
137-
int ret = ::unlink(socket_file.c_str());
138-
if (ret != 0)
139-
LogWarn("remove file %s fail. errno:%d, %s", socket_file.c_str(), errno, strerror(errno));
138+
util::fs::RemoveFile(socket_file);
140139
}
141140
}
142141

@@ -153,7 +152,7 @@ void TcpAcceptor::onClientConnected()
153152
socklen_t addr_len = sizeof(addr);
154153
SocketFd peer_sock = sock_fd_.accept(&addr, &addr_len);
155154
if (peer_sock.isNull()) {
156-
LogWarn("accept fail");
155+
LogNotice("accept fail");
157156
return;
158157
}
159158

modules/network/tcp_connection.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,8 @@ void TcpConnection::onSocketClosed()
150150

151151
void TcpConnection::onError(int errnum)
152152
{
153-
if (errnum == ECONNRESET) {
154-
onSocketClosed();
155-
} else {
156-
LogWarn("errno:%d, %s", errnum, strerror(errnum));
157-
}
153+
LogNotice("errno:%d, %s", errnum, strerror(errnum));
154+
onSocketClosed();
158155
}
159156

160157
}

modules/network/tcp_connector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void TcpConnector::enterConnectingState()
185185
|| (conn_errno == EADDRINUSE) || (conn_errno == EADDRNOTAVAIL)
186186
|| (conn_errno == ECONNREFUSED) || (conn_errno == ENETUNREACH)
187187
|| (conn_errno == ENOENT)) {
188-
LogWarn("connent fail, errno:%d, %s", conn_errno, strerror(conn_errno));
188+
LogNotice("connent fail, errno:%d, %s", conn_errno, strerror(conn_errno));
189189
//! 条件暂时不具备
190190
onConnectFail();
191191

@@ -261,7 +261,7 @@ void TcpConnector::onConnectFail()
261261
connect_fail_cb_();
262262
--cb_level_;
263263
} else
264-
LogWarn("connector stoped");
264+
LogNotice("connector stoped");
265265

266266
state_ = State::kInited;
267267
} else

version.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
# TBOX版本号
2222
TBOX_VERSION_MAJOR := 1
2323
TBOX_VERSION_MINOR := 10
24-
TBOX_VERSION_REVISION := 11
24+
TBOX_VERSION_REVISION := 12

0 commit comments

Comments
 (0)