Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map shared memory region as read-only in receiver #248

Merged
merged 4 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/rust/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ flume = "0.10.14"
uuid = { version = "1.1.2", features = ["v4"] }
capnp = "0.14.11"
bincode = "1.3.3"
shared_memory = "0.12.0"
shared_memory_extended = "0.13.0"
dora-tracing = { workspace = true, optional = true }
arrow = "35.0.0"

Expand Down
3 changes: 2 additions & 1 deletion apis/rust/node/src/event_stream/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use dora_core::{
message::Metadata,
};
use eyre::Context;
use shared_memory::{Shmem, ShmemConf};
use shared_memory_extended::{Shmem, ShmemConf};

#[derive(Debug)]
#[non_exhaustive]
Expand Down Expand Up @@ -78,6 +78,7 @@ impl MappedInputData {
let memory = Box::new(
ShmemConf::new()
.os_id(shared_memory_id)
.writable(false)
.open()
.wrap_err("failed to map shared memory input")?,
);
Expand Down
3 changes: 2 additions & 1 deletion apis/rust/node/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use dora_core::{
message::{uhlc, Metadata, MetadataParameters},
};
use eyre::{bail, WrapErr};
use shared_memory::{Shmem, ShmemConf};
use shared_memory_extended::{Shmem, ShmemConf};
use std::{
collections::{HashMap, VecDeque},
ops::{Deref, DerefMut},
Expand Down Expand Up @@ -219,6 +219,7 @@ impl DoraNode {
None => ShmemHandle(Box::new(
ShmemConf::new()
.size(data_len)
.writable(true)
.create()
.wrap_err("failed to allocate shared memory")?,
)),
Expand Down
1 change: 1 addition & 0 deletions examples/python-operator-dataflow/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def on_input(
dora_input["value"]
.to_numpy()
.reshape((CAMERA_HEIGHT, CAMERA_WIDTH, 3))
.copy() # copy the image because we want to modify it below
)
self.image = frame

Expand Down
2 changes: 1 addition & 1 deletion libraries/shared-memory-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license.workspace = true
[dependencies]
eyre = "0.6.8"
serde = { version = "1.0.152", features = ["derive"] }
shared_memory = "0.12.0"
shared_memory_extended = "0.13.0"
# TODO use upstream release once https://github.com/elast0ny/raw_sync-rs/pull/29 is merged
# Current fix, use personally pushed `raw_sync_2` version.
raw_sync_2 = "0.1.5"
Expand Down
2 changes: 1 addition & 1 deletion libraries/shared-memory-server/src/channel.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use eyre::{eyre, Context};
use raw_sync_2::events::{Event, EventImpl, EventInit, EventState};
use serde::{Deserialize, Serialize};
use shared_memory::Shmem;
use shared_memory_extended::Shmem;
use std::{
mem, slice,
sync::atomic::{AtomicBool, AtomicU64},
Expand Down
2 changes: 1 addition & 1 deletion libraries/shared-memory-server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use self::channel::ShmemChannel;
use eyre::{eyre, Context};
use serde::{Deserialize, Serialize};
pub use shared_memory::{Shmem, ShmemConf};
pub use shared_memory_extended::{Shmem, ShmemConf};
use std::marker::PhantomData;
use std::time::Duration;

Expand Down