| 1441 | } |
| 1442 | |
| 1443 | srt::EConnectStatus srt::CRcvQueue::worker_ProcessConnectionRequest(CUnit* unit, const sockaddr_any& addr) |
| 1444 | { |
| 1445 | HLOGC(cnlog.Debug, |
| 1446 | log << "Got sockID=0 from " << addr.str() << " - trying to resolve it as a connection request..."); |
| 1447 | // Introduced protection because it may potentially happen |
| 1448 | // that another thread could have closed the socket at |
| 1449 | // the same time and inject a bug between checking the |
| 1450 | // pointer for NULL and using it. |
| 1451 | int listener_ret = SRT_REJ_UNKNOWN; |
| 1452 | bool have_listener = false; |
| 1453 | { |
| 1454 | SharedLock shl(m_pListener); |
| 1455 | CUDT* pListener = m_pListener.get_locked(shl); |
| 1456 | |
| 1457 | if (pListener) |
| 1458 | { |
| 1459 | LOGC(cnlog.Debug, log << "PASSING request from: " << addr.str() << " to listener:" << pListener->socketID()); |
| 1460 | listener_ret = pListener->processConnectRequest(addr, unit->m_Packet); |
| 1461 | |
| 1462 | // This function does return a code, but it's hard to say as to whether |
| 1463 | // anything can be done about it. In case when it's stated possible, the |
| 1464 | // listener will try to send some rejection response to the caller, but |
| 1465 | // that's already done inside this function. So it's only used for |
| 1466 | // displaying the error in logs. |
| 1467 | |
| 1468 | have_listener = true; |
| 1469 | } |
| 1470 | } |
| 1471 | |
| 1472 | // NOTE: Rendezvous sockets do bind(), but not listen(). It means that the socket is |
| 1473 | // ready to accept connection requests, but they are not being redirected to the listener |
| 1474 | // socket, as this is not a listener socket at all. This goes then HERE. |
| 1475 | |
| 1476 | if (have_listener) // That is, the above block with m_pListener->processConnectRequest was executed |
| 1477 | { |
| 1478 | LOGC(cnlog.Debug, |
| 1479 | log << CONID() << "Listener got the connection request from: " << addr.str() |
| 1480 | << " result:" << RequestTypeStr(UDTRequestType(listener_ret))); |
| 1481 | return listener_ret == SRT_REJ_UNKNOWN ? CONN_CONTINUE : CONN_REJECT; |
| 1482 | } |
| 1483 | |
| 1484 | // If there's no listener waiting for the packet, just store it into the queue. |
| 1485 | return worker_TryAsyncRend_OrStore(0, unit, addr); // 0 id because the packet came in with that very ID. |
| 1486 | } |
| 1487 | |
| 1488 | srt::EConnectStatus srt::CRcvQueue::worker_ProcessAddressedPacket(int32_t id, CUnit* unit, const sockaddr_any& addr) |
| 1489 | { |
no test coverage detected