Fix the return IoEvents of channel poll
This commit is contained in:
parent
3101d8fa88
commit
0b829ca087
@ -247,17 +247,14 @@ impl<I> Producer<I> {
|
|||||||
|
|
||||||
let writable = {
|
let writable = {
|
||||||
let mut rb_producer = self.inner.lock().unwrap();
|
let mut rb_producer = self.inner.lock().unwrap();
|
||||||
!rb_producer.is_full()
|
!rb_producer.is_full() || self.is_self_shutdown() || self.is_peer_shutdown()
|
||||||
};
|
};
|
||||||
if writable {
|
if writable {
|
||||||
events |= IoEvents::OUT;
|
events |= IoEvents::OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.is_self_shutdown() {
|
|
||||||
events |= IoEvents::HUP;
|
|
||||||
}
|
|
||||||
if self.is_peer_shutdown() {
|
if self.is_peer_shutdown() {
|
||||||
events |= IoEvents::RDHUP;
|
events |= IoEvents::ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
events
|
events
|
||||||
@ -376,15 +373,12 @@ impl<I> Consumer<I> {
|
|||||||
|
|
||||||
let readable = {
|
let readable = {
|
||||||
let mut rb_consumer = self.inner.lock().unwrap();
|
let mut rb_consumer = self.inner.lock().unwrap();
|
||||||
!rb_consumer.is_empty()
|
!rb_consumer.is_empty() || self.is_self_shutdown() || self.is_peer_shutdown()
|
||||||
};
|
};
|
||||||
if readable {
|
if readable {
|
||||||
events |= IoEvents::IN;
|
events |= IoEvents::IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.is_self_shutdown() {
|
|
||||||
events |= IoEvents::RDHUP;
|
|
||||||
}
|
|
||||||
if self.is_peer_shutdown() {
|
if self.is_peer_shutdown() {
|
||||||
events |= IoEvents::HUP;
|
events |= IoEvents::HUP;
|
||||||
}
|
}
|
||||||
@ -417,7 +411,11 @@ impl<I> Consumer<I> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn items_to_consume(&self) -> usize {
|
pub fn items_to_consume(&self) -> usize {
|
||||||
self.inner.lock().unwrap().len()
|
if self.is_self_shutdown() {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
self.inner.lock().unwrap().len()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn capacity(&self) -> usize {
|
pub fn capacity(&self) -> usize {
|
||||||
|
Loading…
Reference in New Issue
Block a user