| 959 | } |
| 960 | |
| 961 | int PollReadT(const TDuration& timeout) { |
| 962 | if (!Connection_) { |
| 963 | return -1; |
| 964 | } |
| 965 | |
| 966 | while (true) { |
| 967 | const int rpoll = Connection_->PollT(CONT_POLL_READ, timeout); |
| 968 | if (!Ssl_ || rpoll) { |
| 969 | return rpoll; |
| 970 | } |
| 971 | |
| 972 | char c = 0; |
| 973 | const int rpeek = SSL_peek(Ssl_.Get(), &c, sizeof(c)); |
| 974 | if (rpeek < 0) { |
| 975 | return -1; |
| 976 | } else if (rpeek > 0) { |
| 977 | return 0; |
| 978 | } else { |
| 979 | if ((SSL_get_shutdown(Ssl_.Get()) & SSL_RECEIVED_SHUTDOWN) != 0) { |
| 980 | Shutdown(); // wait until shutdown is finished |
| 981 | return EIO; |
| 982 | } |
| 983 | } |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | void Shutdown() { |
| 988 | if (Ssl_ && Connection_) { |
no test coverage detected