TarsCloud / TarsCpp

C++ language framework rpc source code implementation
BSD 3-Clause "New" or "Revised" License
522 stars 254 forks source link

tc_epoll_server 多个handle,只有一个在处理 #306

Open sunhmk opened 6 months ago

sunhmk commented 6 months ago

添加一个额外的udp adapter; netthread 个数为4 handle个数也为4 只有一个handle能处理数据,其他三个无效; Thread 14 "uac" hit Breakpoint 10, tars::TC_EpollServer::Connection::getId ( this=0x7fffe80022f0) at /data/tarscpp/Tars/tarscpp/util/include/util/tc_epoll_server.h:535 535 inline uint32_t getId() const { return _uid; } (gdb) p _uid $36 = 4232052737 (gdb) p _uid $37 = 4232052737 (gdb) c Continuing. [Switching to Thread 0x7fffdffff700 (LWP 1508)]

Thread 16 "uac" hit Breakpoint 10, tars::TC_EpollServer::Connection::getId ( this=0x7fffd8001aa0) at /data/tarscpp/Tars/tarscpp/util/include/util/tc_epoll_server.h:535 535 inline uint32_t getId() const { return _uid; } (gdb) p _uid $38 = 4240441345 (gdb) c Continuing. [Switching to Thread 0x7fffecff9700 (LWP 1507)]

Thread 15 "***" hit Breakpoint 10, tars::TC_EpollServer::Connection::getId ( this=0x7fffe4001aa0) at ..../tarscpp/util/include/util/tc_epoll_server.h:535 535 inline uint32_t getId() const { return _uid; } (gdb) p _uid $39 = 4236247041 (gdb) c Continuing. [Switching to Thread 0x7fffdf7fe700 (LWP 1509)]

Thread 17 "***" hit Breakpoint 10, tars::TC_EpollServer::Connection::getId ( this=0x7fffd0001aa0) at ..../tarscpp/util/include/util/tc_epoll_server.h:535 535 inline uint32_t getId() const { return _uid; } (gdb) p _uid $40 = 4244635649

(gdb) p 4232052737 % 4 $1 = 1 (gdb) p 4240441345 % 4 $2 = 1 (gdb) p 4236247041 % 4 $3 = 1 (gdb) p 4244635649 % 4 $4 = 1

ruanshudong commented 6 months ago

启用了队列模式?

sunhmk commented 6 months ago

是的。 请教下,udp服务端,如果还希望每次接收到来自同一个客户端的数据由同一个handle处理,怎么处理比较高效?

启用了队列模式?

ruanshudong commented 6 months ago

udp启用队列模式没用, 因为句柄只有一个, 这种情况, 估计你得自己处理了, 到handle以后, 自己根据来源, 分到自己的线程处理了