wasmer_wasix/journal/effector/syscalls/
sock_pair.rs

1use super::*;
2
3impl JournalEffector {
4    // Note: since the current implementation uses a pipe, we don't store the
5    // socket properties (domain, address family, etc.) in the journal.
6    // Once the sock_pair syscall is fixed, we should create a SocketPairV2
7    // entry that stores the socket properties as well. This ensures
8    // forward-compatibility when that change is implemented.
9    pub fn save_sock_pair(
10        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
11        fd1: Fd,
12        fd2: Fd,
13    ) -> anyhow::Result<()> {
14        Self::save_event(ctx, JournalEntry::SocketPairV1 { fd1, fd2 })
15    }
16
17    pub fn apply_sock_pair(
18        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
19        fd1: Fd,
20        fd2: Fd,
21    ) -> anyhow::Result<()> {
22        crate::syscalls::sock_pair_internal(ctx, Some(fd1), Some(fd2)).map_err(|err| {
23            anyhow::format_err!("journal restore error: failed to create socket pair - {err}")
24        })?;
25        Ok(())
26    }
27}