MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / notify

Method notify

virtio-devices/src/vsock/csm/connection.rs:436–479  ·  view source on GitHub ↗

Notify the connection about an event (or set of events) that it was interested in.

(&mut self, evset: epoll::Events)

Source from the content-addressed store, hash-verified

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
482impl<S> VsockConnection<S>

Callers 3

notify_epollinMethod · 0.45
notify_epolloutMethod · 0.45
test_tx_bufferingFunction · 0.45

Calls 7

containsMethod · 0.80
flush_toMethod · 0.80
kindMethod · 0.80
killMethod · 0.80
insertMethod · 0.45
is_emptyMethod · 0.45

Tested by 1

test_tx_bufferingFunction · 0.36