Notify the connection about an event (or set of events) that it was interested in.
(&mut self, evset: epoll::Events)
| 434 | /// Notify the connection about an event (or set of events) that it was interested in. |
| 435 | /// |
| 436 | fn notify(&mut self, evset: epoll::Events) { |
| 437 | if evset.contains(epoll::Events::EPOLLIN) { |
| 438 | // Data can be read from the host stream. Setting a Rw pending indication, so that |
| 439 | // the muxer will know to call `recv_pkt()` later. |
| 440 | self.pending_rx.insert(PendingRx::Rw); |
| 441 | } |
| 442 | |
| 443 | if evset.contains(epoll::Events::EPOLLOUT) { |
| 444 | // Data can be written to the host stream. Time to flush out the TX buffer. |
| 445 | // |
| 446 | if self.tx_buf.is_empty() { |
| 447 | info!("vsock: connection received unexpected EPOLLOUT event"); |
| 448 | return; |
| 449 | } |
| 450 | let flushed = self |
| 451 | .tx_buf |
| 452 | .flush_to(&mut self.stream) |
| 453 | .unwrap_or_else(|err| { |
| 454 | warn!( |
| 455 | "vsock: error flushing TX buf for (lp={}, pp={}): {:?}", |
| 456 | self.local_port, self.peer_port, err |
| 457 | ); |
| 458 | match err { |
| 459 | Error::TxBufFlush(inner) if inner.kind() == ErrorKind::WouldBlock => { |
| 460 | // This should never happen (EWOULDBLOCK after EPOLLOUT), but |
| 461 | // it does, so let's absorb it. |
| 462 | } |
| 463 | _ => self.kill(), |
| 464 | } |
| 465 | 0 |
| 466 | }); |
| 467 | self.fwd_cnt += Wrapping(flushed as u32); |
| 468 | |
| 469 | // If this connection was shutting down, but is waiting to drain the TX buffer |
| 470 | // before forceful termination, the wait might be over. |
| 471 | if self.state == ConnState::PeerClosed(true, true) && self.tx_buf.is_empty() { |
| 472 | self.pending_rx.insert(PendingRx::Rst); |
| 473 | } else if self.peer_needs_credit_update() { |
| 474 | // If we've freed up some more buffer space, we may need to let the peer know it |
| 475 | // can safely send more data our way. |
| 476 | self.pending_rx.insert(PendingRx::CreditUpdate); |
| 477 | } |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | impl<S> VsockConnection<S> |