(&self, needs: SslNeeds, deadline: &SocketDeadline)
| 2300 | } |
| 2301 | |
| 2302 | fn select(&self, needs: SslNeeds, deadline: &SocketDeadline) -> SelectRet { |
| 2303 | let sock = match self.0.sock_opt() { |
| 2304 | Some(s) => s, |
| 2305 | None => return SelectRet::Closed, |
| 2306 | }; |
| 2307 | // For blocking sockets without timeout, call sock_select with None timeout |
| 2308 | // to actually block waiting for data instead of busy-looping |
| 2309 | let timeout = match &deadline { |
| 2310 | Ok(deadline) => match deadline.checked_duration_since(Instant::now()) { |
| 2311 | Some(d) => Some(d), |
| 2312 | None => return SelectRet::TimedOut, |
| 2313 | }, |
| 2314 | Err(true) => None, // Blocking: no timeout, wait indefinitely |
| 2315 | Err(false) => return SelectRet::Nonblocking, |
| 2316 | }; |
| 2317 | let res = socket::sock_select( |
| 2318 | &sock, |
| 2319 | match needs { |
| 2320 | SslNeeds::Read => socket::SelectKind::Read, |
| 2321 | SslNeeds::Write => socket::SelectKind::Write, |
| 2322 | }, |
| 2323 | timeout, |
| 2324 | ); |
| 2325 | match res { |
| 2326 | Ok(true) => SelectRet::TimedOut, |
| 2327 | _ => SelectRet::Ok, |
| 2328 | } |
| 2329 | } |
| 2330 | |
| 2331 | fn socket_needs( |
| 2332 | &self, |
no test coverage detected