mirror of
https://github.com/facebookexperimental/reverie.git
synced 2024-10-23 04:46:36 +00:00
Don't return a Result for RPC messages
Summary: If an RPC fails to send, there isn't much that can be done to handle it. In all call sites so far, they all just unwrap the error because it can't be handled properly. If an RPC fails, it is a programmer error (because the request/response failed to serialize/deserialize) and indicates a bug in our code. Differential Revision: D37563857 fbshipit-source-id: 267072709f4230732a13989aaf74b50fd0908337
This commit is contained in:
parent
6813d9a7b2
commit
5df280b851
13 changed files with 25 additions and 26 deletions
|
@ -156,7 +156,7 @@ impl Tool for ChromeTrace {
|
|||
events: thread_state.events,
|
||||
exit_status,
|
||||
})
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ impl Tool for CounterLocal {
|
|||
syscall: Syscall,
|
||||
) -> Result<i64, Error> {
|
||||
let sysno = syscall.number();
|
||||
let _ = guest.send_rpc(IncrMsg(sysno)).await?;
|
||||
let _ = guest.send_rpc(IncrMsg(sysno)).await;
|
||||
guest.tail_inject(syscall).await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ impl Tool for CounterLocal {
|
|||
"At ExitProc (pid {}), contributing {} to global count.",
|
||||
pid, count
|
||||
);
|
||||
let _ = global_state.send_rpc(IncrMsg(count, threads)).await?;
|
||||
let _ = global_state.send_rpc(IncrMsg(count, threads)).await;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2173,7 +2173,7 @@ impl<L: Tool + 'static> GlobalRPC<L::GlobalState> for TracedTask<L> {
|
|||
async fn send_rpc<'a>(
|
||||
&'a self,
|
||||
args: <L::GlobalState as GlobalTool>::Request,
|
||||
) -> Result<<L::GlobalState as GlobalTool>::Response, reverie::Error> {
|
||||
) -> <L::GlobalState as GlobalTool>::Response {
|
||||
let wrapped = WrappedFrom(self.tid(), &self.global_state);
|
||||
wrapped.send_rpc(args).await
|
||||
}
|
||||
|
@ -2189,7 +2189,7 @@ struct WrappedFrom<'a, G: GlobalTool>(Tid, &'a GlobalState<G>);
|
|||
|
||||
#[async_trait]
|
||||
impl<'a, G: GlobalTool> GlobalRPC<G> for WrappedFrom<'a, G> {
|
||||
async fn send_rpc(&self, args: G::Request) -> Result<G::Response, reverie::Error> {
|
||||
async fn send_rpc(&self, args: G::Request) -> G::Response {
|
||||
// In debugging mode we round-trip through a serialized representation
|
||||
// to make sure it works.
|
||||
let deserial = if cfg!(debug_assertions) {
|
||||
|
@ -2198,8 +2198,7 @@ impl<'a, G: GlobalTool> GlobalRPC<G> for WrappedFrom<'a, G> {
|
|||
} else {
|
||||
args
|
||||
};
|
||||
let x = self.1.gs_ref.receive_rpc(self.0, deserial).await;
|
||||
Ok(x)
|
||||
self.1.gs_ref.receive_rpc(self.0, deserial).await
|
||||
}
|
||||
fn config(&self) -> &G::Config {
|
||||
&self.1.cfg
|
||||
|
|
|
@ -280,7 +280,7 @@ where
|
|||
async fn send_rpc(
|
||||
&self,
|
||||
message: <U::GlobalState as GlobalTool>::Request,
|
||||
) -> Result<<U::GlobalState as GlobalTool>::Response, Error> {
|
||||
) -> <U::GlobalState as GlobalTool>::Response {
|
||||
self.inner.send_rpc(message).await
|
||||
}
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ impl Tool for () {
|
|||
pub trait GlobalRPC<G: GlobalTool>: Sync {
|
||||
/// Send an RPC message to wherever the global state is stored, synchronously
|
||||
/// blocks the current thread until a response is received.
|
||||
async fn send_rpc(&self, message: G::Request) -> Result<G::Response, Error>;
|
||||
async fn send_rpc(&self, message: G::Request) -> G::Response;
|
||||
|
||||
/// Return the read-only tool configuration
|
||||
fn config(&self) -> &G::Config;
|
||||
|
|
|
@ -86,7 +86,7 @@ impl Tool for CounterLocal {
|
|||
syscall: Syscall,
|
||||
) -> Result<i64, Error> {
|
||||
let sysno = syscall.number();
|
||||
let _ = guest.send_rpc(IncrMsg(sysno)).await?;
|
||||
let _ = guest.send_rpc(IncrMsg(sysno)).await;
|
||||
guest.tail_inject(syscall).await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,12 +101,12 @@ impl Tool for LocalState {
|
|||
type GlobalState = GlobalState;
|
||||
|
||||
async fn handle_thread_start<T: Guest<Self>>(&self, guest: &mut T) -> Result<(), Error> {
|
||||
guest.send_rpc(IncrMsg::Increment).await.unwrap();
|
||||
guest.send_rpc(IncrMsg::Increment).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_post_exec<T: Guest<Self>>(&self, guest: &mut T) -> Result<(), Errno> {
|
||||
guest.send_rpc(IncrMsg::Increment).await.unwrap();
|
||||
guest.send_rpc(IncrMsg::Increment).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -117,12 +117,12 @@ impl Tool for LocalState {
|
|||
) -> Result<i64, Error> {
|
||||
if let Syscall::ClockGetres(_) = syscall {
|
||||
// clock_getres denotes the start/end of the busywait
|
||||
guest.send_rpc(IncrMsg::ToggleCollection).await?;
|
||||
guest.send_rpc(IncrMsg::ToggleCollection).await;
|
||||
if guest.config().set_timer {
|
||||
guest.set_timer_precise(TIMEOUT).unwrap();
|
||||
}
|
||||
} else {
|
||||
guest.send_rpc(IncrMsg::Increment).await?;
|
||||
guest.send_rpc(IncrMsg::Increment).await;
|
||||
}
|
||||
guest.tail_inject(syscall).await
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ impl Tool for LocalState {
|
|||
eax: u32,
|
||||
ecx: u32,
|
||||
) -> Result<CpuIdResult, Errno> {
|
||||
guest.send_rpc(IncrMsg::Increment).await.unwrap();
|
||||
guest.send_rpc(IncrMsg::Increment).await;
|
||||
Ok(cpuid!(eax, ecx))
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ impl Tool for LocalState {
|
|||
guest: &mut T,
|
||||
request: Rdtsc,
|
||||
) -> Result<RdtscResult, Errno> {
|
||||
guest.send_rpc(IncrMsg::Increment).await.unwrap();
|
||||
guest.send_rpc(IncrMsg::Increment).await;
|
||||
Ok(RdtscResult::new(request))
|
||||
}
|
||||
|
||||
|
@ -151,12 +151,12 @@ impl Tool for LocalState {
|
|||
guest: &mut T,
|
||||
signal: Signal,
|
||||
) -> Result<Option<Signal>, Errno> {
|
||||
guest.send_rpc(IncrMsg::Increment).await.unwrap();
|
||||
guest.send_rpc(IncrMsg::Increment).await;
|
||||
Ok(Some(signal))
|
||||
}
|
||||
|
||||
async fn handle_timer_event<T: Guest<Self>>(&self, guest: &mut T) {
|
||||
guest.send_rpc(IncrMsg::TimerEvent).await.unwrap();
|
||||
guest.send_rpc(IncrMsg::TimerEvent).await;
|
||||
guest.set_timer_precise(TIMEOUT).unwrap();
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ impl Tool for LocalState {
|
|||
_thread_state: Self::ThreadState,
|
||||
_exit_status: ExitStatus,
|
||||
) -> Result<(), Error> {
|
||||
global_state.send_rpc(IncrMsg::Increment).await?;
|
||||
global_state.send_rpc(IncrMsg::Increment).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ impl Tool for LocalState {
|
|||
global_state: &G,
|
||||
_exit_status: ExitStatus,
|
||||
) -> Result<(), Error> {
|
||||
global_state.send_rpc(IncrMsg::Increment).await?;
|
||||
global_state.send_rpc(IncrMsg::Increment).await;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ impl Tool for InjectExitTool {
|
|||
global_state: &G,
|
||||
exit_status: ExitStatus,
|
||||
) -> Result<(), Error> {
|
||||
global_state.send_rpc(exit_status).await?;
|
||||
global_state.send_rpc(exit_status).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ impl Tool for TestTool {
|
|||
eprintln!("Root thread starting...");
|
||||
} else {
|
||||
eprintln!("Delaying child thread!");
|
||||
guest.send_rpc(()).await.unwrap();
|
||||
guest.send_rpc(()).await;
|
||||
eprintln!("Done delaying child thread!");
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -70,7 +70,7 @@ impl Tool for LocalState {
|
|||
guest: &mut T,
|
||||
request: Rdtsc,
|
||||
) -> Result<RdtscResult, Errno> {
|
||||
let tsc = guest.send_rpc(request).await.unwrap();
|
||||
let tsc = guest.send_rpc(request).await;
|
||||
println!("handle_rdtsc: returned {:?}", tsc);
|
||||
Ok(tsc)
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ impl Tool for TestTool {
|
|||
) -> Result<(), Error> {
|
||||
global_state
|
||||
.send_rpc(self.threads.into_inner().unwrap())
|
||||
.await?;
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ impl Tool for LocalState {
|
|||
}
|
||||
|
||||
async fn handle_timer_event<T: Guest<Self>>(&self, guest: &mut T) {
|
||||
guest.send_rpc(IncrMsg::Timer).await.unwrap();
|
||||
guest.send_rpc(IncrMsg::Timer).await;
|
||||
let clock_value = guest.read_clock().unwrap();
|
||||
let ts = guest.thread_state();
|
||||
if let Some(val) = ts.timer_assertion {
|
||||
|
@ -189,7 +189,7 @@ impl Tool for LocalState {
|
|||
guest: &mut T,
|
||||
signal: Signal,
|
||||
) -> Result<Option<Signal>, Errno> {
|
||||
guest.send_rpc(IncrMsg::Signal).await.unwrap();
|
||||
guest.send_rpc(IncrMsg::Signal).await;
|
||||
Ok(Some(signal))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue