Skip to content

Commit 0421201

Browse files
committed
修复UDP链接id逻辑错误
1 parent e1e68cd commit 0421201

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Network/UdpServer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ SessionHelper::Ptr UdpServer::createSession(const PeerIdType &id, Buffer::Ptr &b
290290
if (!strong_self) {
291291
return;
292292
}
293-
293+
auto new_id = makeSockId(addr, addr_len);
294294
//快速判断是否为本会话的的数据, 通常应该成立 [AUTO-TRANSLATED:d5d147e4]
295295
//Quickly determine if it's data for the current session, usually should be true
296-
if (id == makeSockId(addr, addr_len)) {
296+
if (id == new_id) {
297297
if (auto strong_helper = weak_helper.lock()) {
298298
emitSessionRecv(strong_helper, buf);
299299
}
@@ -302,7 +302,7 @@ SessionHelper::Ptr UdpServer::createSession(const PeerIdType &id, Buffer::Ptr &b
302302

303303
//收到非本peer fd的数据,让server去派发此数据到合适的session对象 [AUTO-TRANSLATED:e5f44445]
304304
//Received data from a non-current peer fd, let the server dispatch this data to the appropriate session object
305-
strong_self->onRead_l(false, id, buf, addr, addr_len);
305+
strong_self->onRead_l(false, new_id, buf, addr, addr_len);
306306
});
307307
socket->setOnErr([weak_self, weak_helper, id](const SockException &err) {
308308
// 在本函数作用域结束时移除会话对象 [AUTO-TRANSLATED:b2ade305]

0 commit comments

Comments
 (0)