| 424 | |
| 425 | |
| 426 | void cSocketThreads::cSocketThread::PrepareSets(fd_set * a_Read, fd_set * a_Write, cSocket::xSocket & a_Highest) |
| 427 | { |
| 428 | FD_ZERO(a_Read); |
| 429 | FD_ZERO(a_Write); |
| 430 | FD_SET(m_ControlSocket1.GetSocket(), a_Read); |
| 431 | |
| 432 | cCSLock Lock(m_Parent->m_CS); |
| 433 | for (int i = m_NumSlots - 1; i >= 0; --i) |
| 434 | { |
| 435 | if (!m_Slots[i].m_Socket.IsValid()) |
| 436 | { |
| 437 | continue; |
| 438 | } |
| 439 | if (m_Slots[i].m_State == sSlot::ssRemoteClosed) |
| 440 | { |
| 441 | // This socket won't provide nor consume any data anymore, don't put it in the Set |
| 442 | continue; |
| 443 | } |
| 444 | cSocket::xSocket s = m_Slots[i].m_Socket.GetSocket(); |
| 445 | FD_SET(s, a_Read); |
| 446 | if (s > a_Highest) |
| 447 | { |
| 448 | a_Highest = s; |
| 449 | } |
| 450 | if (!m_Slots[i].m_Outgoing.empty()) |
| 451 | { |
| 452 | // There's outgoing data for the socket, put it in the Write set |
| 453 | FD_SET(s, a_Write); |
| 454 | } |
| 455 | } // for i - m_Slots[] |
| 456 | } |
| 457 | |
| 458 | |
| 459 | |