| 356 | |
| 357 | template <typename Callable> |
| 358 | int waitForOperationComplete(const Callable& operation, const sf::TimeoutWithPredicate& timeout) |
| 359 | { |
| 360 | while (true) |
| 361 | { |
| 362 | if (const auto result = operation(); result != LIBSSH2_ERROR_EAGAIN) |
| 363 | return result; // Operation completed without having to block |
| 364 | |
| 365 | // Wait for socket to become ready |
| 366 | const auto directions = libssh2_session_block_directions(ssh2Session.get()); |
| 367 | if (directions == (LIBSSH2_SESSION_BLOCK_INBOUND | LIBSSH2_SESSION_BLOCK_OUTBOUND)) |
| 368 | { |
| 369 | if (selectorEither.wait(timeout.getPeriod())) |
| 370 | continue; |
| 371 | } |
| 372 | else if (directions == LIBSSH2_SESSION_BLOCK_OUTBOUND) |
| 373 | { |
| 374 | if (selectorSend.wait(timeout.getPeriod())) |
| 375 | continue; |
| 376 | } |
| 377 | else |
| 378 | { |
| 379 | if (selectorRecv.wait(timeout.getPeriod())) |
| 380 | continue; |
| 381 | } |
| 382 | |
| 383 | if (!timeout.getPredicate()()) |
| 384 | return LIBSSH2_ERROR_EAGAIN; // Gave up waiting |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | Sftp::Result initializeSftp(const TimeoutWithPredicate& timeout) |
| 389 | { |
no test coverage detected