Skip to content

Commit 8514614

Browse files
committed
Remove redundant fclose
1 parent ca2bc9a commit 8514614

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

src/zend/fibers.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use lazy_static::lazy_static;
1515
use tokio::runtime::Runtime;
1616
use std::os::fd::AsRawFd;
1717

18-
use super::borrow_unchecked;
18+
use super::{borrow_unchecked, printf};
1919

2020
lazy_static! {
2121
pub static ref RUNTIME: Runtime = Runtime::new().expect("Could not allocate runtime");
@@ -87,7 +87,17 @@ impl EventLoop {
8787

8888
pub fn wakeup() -> PhpResult<()> {
8989
EVENTLOOP.with_borrow_mut(|c| {
90-
c.as_mut().unwrap().wakeup_internal()
90+
let c = c.as_mut().unwrap();
91+
92+
c.notify_receiver.read_exact(&mut c.dummy).unwrap();
93+
94+
for fiber_id in c.receiver.try_iter() {
95+
if let Some(fiber) = c.fibers.get_index_mut(fiber_id) {
96+
fiber.object_mut().unwrap().try_call_method("resume", vec![])?;
97+
c.fibers.remove_index(fiber_id);
98+
}
99+
}
100+
Ok(())
91101
})
92102
}
93103

@@ -113,23 +123,4 @@ impl EventLoop {
113123
get_current_suspension: Function::try_from_method("\\Revolt\\EventLoop", "getSuspension").ok_or("\\Revolt\\EventLoop::getSuspension does not exist")?,
114124
})
115125
}
116-
117-
fn wakeup_internal(&mut self) -> PhpResult<()> {
118-
self.notify_receiver.read_exact(&mut self.dummy).unwrap();
119-
120-
for fiber_id in self.receiver.try_iter() {
121-
if let Some(fiber) = self.fibers.get_index_mut(fiber_id) {
122-
fiber.object_mut().unwrap().try_call_method("resume", vec![])?;
123-
self.fibers.remove_index(fiber_id);
124-
}
125-
}
126-
Ok(())
127-
}
128-
}
129-
130-
impl Drop for EventLoop {
131-
fn drop(&mut self) {
132-
unsafe { libc::close(self.notify_receiver.as_raw_fd()) };
133-
unsafe { libc::close(self.notify_sender.as_raw_fd()) };
134-
}
135126
}

0 commit comments

Comments
 (0)