| 534 | } |
| 535 | |
| 536 | TUdpRecvPacket* TAbstractSocket::RecvImpl(TUdpHostRecvBufAlloc* buf, sockaddr_in6* srcAddr, sockaddr_in6* dstAddr) { |
| 537 | Y_ASSERT(IsValid()); |
| 538 | |
| 539 | const TIoVec iov = CreateIoVec(buf->GetDataPtr(), buf->GetBufSize()); |
| 540 | char controllBuffer[CTRL_BUFFER_SIZE]; //used to get dst address from socket |
| 541 | TMsgHdr hdr = CreateRecvMsgHdr(srcAddr, iov, controllBuffer); |
| 542 | |
| 543 | const ssize_t rv = TAbstractSocket::RecvMsgImpl(&hdr, 0); |
| 544 | if (rv < 0) { |
| 545 | Y_ASSERT(LastSystemError() == EAGAIN || LastSystemError() == EWOULDBLOCK); |
| 546 | return nullptr; |
| 547 | } |
| 548 | if (dstAddr && !ExtractDestinationAddress(hdr, dstAddr)) { |
| 549 | //fprintf(stderr, "can`t get destination ip\n"); |
| 550 | } |
| 551 | |
| 552 | // we extract packet and allocate new buffer only if packet arrived |
| 553 | TUdpRecvPacket* result = buf->ExtractPacket(); |
| 554 | result->DataStart = 0; |
| 555 | result->DataSize = (int)rv; |
| 556 | return result; |
| 557 | } |
| 558 | |
| 559 | // thread-safe |
| 560 | int TAbstractSocket::RecvMMsgImpl(TMMsgHdr* msgvec, unsigned int vlen, unsigned int flags, timespec* timeout) { |
nothing calls this directly
no test coverage detected