Skip to content

Commit 0bab6ea

Browse files
committed
syscall mod is split into more modules based on syscall names
1 parent d945dca commit 0bab6ea

File tree

13 files changed

+359
-716
lines changed

13 files changed

+359
-716
lines changed

TODO.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
syscall mod is split into more modules based on system call names
2-
31
EventLoops does not perform load balancing
42

53
refactor CI

open-coroutine-core/src/net/event_loop/mod.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -181,27 +181,30 @@ impl EventLoops {
181181

182182
pub fn stop() {
183183
warn!("open-coroutine is exiting...");
184-
EVENT_LOOP_STARTED.store(false, Ordering::Release);
185-
// wait for the event-loops to stop
186-
let (lock, cvar) = EVENT_LOOP_STOP.as_ref();
187-
let result = cvar
188-
.wait_timeout_while(
189-
lock.lock().unwrap(),
190-
Duration::from_millis(30000),
191-
|stopped| {
192-
stopped.load(Ordering::Acquire)
193-
< EVENT_LOOP_START_COUNT.load(Ordering::Acquire) - 1
194-
},
195-
)
196-
.unwrap()
197-
.1;
184+
if EVENT_LOOP_STARTED
185+
.compare_exchange(true, false, Ordering::Acquire, Ordering::Relaxed)
186+
.is_ok()
187+
{
188+
// wait for the event-loops to stop
189+
let (lock, cvar) = EVENT_LOOP_STOP.as_ref();
190+
let result = cvar
191+
.wait_timeout_while(
192+
lock.lock().unwrap(),
193+
Duration::from_millis(30000),
194+
|stopped| {
195+
stopped.load(Ordering::Acquire)
196+
< EVENT_LOOP_START_COUNT.load(Ordering::Acquire) - 1
197+
},
198+
)
199+
.unwrap()
200+
.1;
201+
if result.timed_out() {
202+
crate::error!("open-coroutine didn't exit successfully within 30 seconds !");
203+
}
204+
}
198205
#[cfg(all(unix, feature = "preemptive-schedule"))]
199206
crate::monitor::Monitor::stop();
200-
if result.timed_out() {
201-
crate::error!("open-coroutine didn't exit successfully within 30 seconds !");
202-
} else {
203-
crate::info!("open-coroutine exit successfully !");
204-
}
207+
crate::info!("open-coroutine exit successfully !");
205208
}
206209

207210
pub fn submit_co(

open-coroutine-core/src/syscall/facade.rs

Lines changed: 0 additions & 84 deletions
This file was deleted.

open-coroutine-core/src/syscall/io_uring.rs

Lines changed: 0 additions & 93 deletions
This file was deleted.

open-coroutine-core/src/syscall/mod.rs

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,6 @@
1-
#[cfg(target_os = "linux")]
2-
use libc::epoll_event;
3-
#[cfg(unix)]
4-
use libc::{msghdr, off_t, size_t, sockaddr, socklen_t, ssize_t};
5-
#[cfg(unix)]
6-
use std::ffi::{c_int, c_void};
7-
81
#[cfg(unix)]
92
pub mod common;
103

11-
#[cfg(unix)]
12-
pub mod raw;
13-
14-
#[cfg(unix)]
15-
pub mod nio;
16-
17-
#[allow(unused_variables)]
18-
#[cfg(all(target_os = "linux", feature = "io_uring"))]
19-
pub mod io_uring;
20-
21-
#[cfg(unix)]
22-
pub mod state;
23-
24-
#[cfg(unix)]
25-
mod facade;
26-
#[cfg(unix)]
27-
pub use facade::*;
28-
29-
#[cfg(unix)]
30-
pub trait UnixSyscall {
31-
/// write
32-
33-
extern "C" fn sendto(
34-
&self,
35-
fn_ptr: Option<
36-
&extern "C" fn(
37-
c_int,
38-
*const c_void,
39-
size_t,
40-
c_int,
41-
*const sockaddr,
42-
socklen_t,
43-
) -> ssize_t,
44-
>,
45-
fd: c_int,
46-
buf: *const c_void,
47-
len: size_t,
48-
flags: c_int,
49-
addr: *const sockaddr,
50-
addrlen: socklen_t,
51-
) -> ssize_t;
52-
53-
extern "C" fn write(
54-
&self,
55-
fn_ptr: Option<&extern "C" fn(c_int, *const c_void, size_t) -> ssize_t>,
56-
fd: c_int,
57-
buf: *const c_void,
58-
count: size_t,
59-
) -> ssize_t;
60-
61-
extern "C" fn pwrite(
62-
&self,
63-
fn_ptr: Option<&extern "C" fn(c_int, *const c_void, size_t, off_t) -> ssize_t>,
64-
fd: c_int,
65-
buf: *const c_void,
66-
count: size_t,
67-
offset: off_t,
68-
) -> ssize_t;
69-
70-
extern "C" fn sendmsg(
71-
&self,
72-
fn_ptr: Option<&extern "C" fn(c_int, *const msghdr, c_int) -> ssize_t>,
73-
fd: c_int,
74-
msg: *const msghdr,
75-
flags: c_int,
76-
) -> ssize_t;
77-
}
78-
79-
#[cfg(target_os = "linux")]
80-
pub trait LinuxSyscall: UnixSyscall {
81-
/// poll
82-
83-
extern "C" fn epoll_ctl(
84-
&self,
85-
fn_ptr: Option<&extern "C" fn(c_int, c_int, c_int, *mut epoll_event) -> c_int>,
86-
epfd: c_int,
87-
op: c_int,
88-
fd: c_int,
89-
event: *mut epoll_event,
90-
) -> c_int;
91-
}
92-
93-
#[allow(unused_imports)]
944
#[cfg(unix)]
955
pub use unix::*;
966

0 commit comments

Comments
 (0)