| 195 | |
| 196 | private: |
| 197 | THolder<NTesting::IPort> TryAcquirePort(ui16 port) const { |
| 198 | auto lock = MakeHolder<TFileLock>(TString(SyncDir_ / ::ToString(port))); |
| 199 | if (!lock->TryAcquire()) { |
| 200 | return nullptr; |
| 201 | } |
| 202 | |
| 203 | TInet6StreamSocket sock; |
| 204 | Y_VERIFY_SYSERROR(INVALID_SOCKET != static_cast<SOCKET>(sock)); |
| 205 | |
| 206 | TSockAddrInet6 addr("::", port); |
| 207 | if (sock.Bind(&addr) != 0) { |
| 208 | lock->Release(); |
| 209 | Y_ABORT_UNLESS(EADDRINUSE == LastSystemError(), "unexpected error: %d, port: %d", LastSystemError(), port); |
| 210 | return nullptr; |
| 211 | } |
| 212 | return MakeHolder<TPortGuard>(port, std::move(lock)); |
| 213 | } |
| 214 | |
| 215 | private: |
| 216 | TFsPath SyncDir_; |
nothing calls this directly
no test coverage detected