| 559 | #endif |
| 560 | |
| 561 | void TSocketHolder::Close() noexcept { |
| 562 | if (Fd_ != INVALID_SOCKET) { |
| 563 | bool ok = (closesocket(Fd_) == 0); |
| 564 | if (!ok) { |
| 565 | // Do not quietly close bad descriptor, |
| 566 | // because often it means double close |
| 567 | // that is disasterous |
| 568 | #ifdef _win_ |
| 569 | Y_ABORT_UNLESS(WSAGetLastError() != WSAENOTSOCK, "must not quietly close bad socket descriptor"); |
| 570 | #elif defined(_unix_) |
| 571 | Y_ABORT_UNLESS(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_)); |
| 572 | #else |
| 573 | #error unsupported platform |
| 574 | #endif |
| 575 | } |
| 576 | |
| 577 | Fd_ = INVALID_SOCKET; |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | class TSocket::TImpl: public TAtomicRefCount<TImpl> { |
| 582 | using TOps = TSocket::TOps; |