@@ -1307,7 +1307,7 @@ bool CConnman::GenerateSelectSet(std::set<SOCKET> &recv_set, std::set<SOCKET> &s
13071307 return !recv_set.empty () || !send_set.empty () || !error_set.empty ();
13081308}
13091309
1310- void CConnman::SocketHandler ( )
1310+ void CConnman::SocketEvents (std::set<SOCKET> &recv_set, std::set<SOCKET> &send_set, std::set<SOCKET> &error_set )
13111311{
13121312 std::set<SOCKET> recv_select_set, send_select_set, error_select_set;
13131313 if (!GenerateSelectSet (recv_select_set, send_select_set, error_select_set)) {
@@ -1362,12 +1362,38 @@ void CConnman::SocketHandler()
13621362 return ;
13631363 }
13641364
1365+ for (SOCKET hSocket : recv_select_set) {
1366+ if (FD_ISSET (hSocket, &fdsetRecv)) {
1367+ recv_set.insert (hSocket);
1368+ }
1369+ }
1370+
1371+ for (SOCKET hSocket : send_select_set) {
1372+ if (FD_ISSET (hSocket, &fdsetSend)) {
1373+ send_set.insert (hSocket);
1374+ }
1375+ }
1376+
1377+ for (SOCKET hSocket : error_select_set) {
1378+ if (FD_ISSET (hSocket, &fdsetError)) {
1379+ error_set.insert (hSocket);
1380+ }
1381+ }
1382+ }
1383+
1384+ void CConnman::SocketHandler ()
1385+ {
1386+ std::set<SOCKET> recv_set, send_set, error_set;
1387+ SocketEvents (recv_set, send_set, error_set);
1388+
1389+ if (interruptNet) return ;
1390+
13651391 //
13661392 // Accept new connections
13671393 //
13681394 for (const ListenSocket& hListenSocket : vhListenSocket)
13691395 {
1370- if (hListenSocket.socket != INVALID_SOCKET && FD_ISSET (hListenSocket.socket , &fdsetRecv) )
1396+ if (hListenSocket.socket != INVALID_SOCKET && recv_set. count (hListenSocket.socket ) > 0 )
13711397 {
13721398 AcceptConnection (hListenSocket);
13731399 }
@@ -1398,9 +1424,9 @@ void CConnman::SocketHandler()
13981424 LOCK (pnode->cs_hSocket );
13991425 if (pnode->hSocket == INVALID_SOCKET)
14001426 continue ;
1401- recvSet = FD_ISSET (pnode->hSocket , &fdsetRecv) ;
1402- sendSet = FD_ISSET (pnode->hSocket , &fdsetSend) ;
1403- errorSet = FD_ISSET (pnode->hSocket , &fdsetError) ;
1427+ recvSet = recv_set. count (pnode->hSocket ) > 0 ;
1428+ sendSet = send_set. count (pnode->hSocket ) > 0 ;
1429+ errorSet = error_set. count (pnode->hSocket ) > 0 ;
14041430 }
14051431 if (recvSet || errorSet)
14061432 {
0 commit comments