wasmer_wasix/journal/effector/syscalls/
sock_send_file.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::syscalls::sock_send_file_internal;

use super::*;

impl JournalEffector {
    pub fn save_sock_send_file<M: MemorySize>(
        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
        socket_fd: Fd,
        file_fd: Fd,
        offset: Filesize,
        count: Filesize,
    ) -> anyhow::Result<()> {
        Self::save_event(
            ctx,
            JournalEntry::SocketSendFileV1 {
                socket_fd,
                file_fd,
                offset,
                count,
            },
        )
    }

    pub fn apply_sock_send_file(
        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
        socket_fd: Fd,
        file_fd: Fd,
        offset: Filesize,
        count: Filesize,
    ) -> anyhow::Result<()> {
        sock_send_file_internal(ctx, socket_fd, file_fd, offset, count)?.map_err(|err| {
            anyhow::format_err!(
                "journal restore error: failed to send_file on socket (sock={}, in_fd={}, offset={}, count={}) - {}",
                socket_fd,
                file_fd,
                offset,
                count,
                err
            )
        })?;
        Ok(())
    }
}