Skip to content

Commit

Permalink
[eclipse-uprotocol#35] Add check for shared mem payload type
Browse files Browse the repository at this point in the history
* Prevent payloads of shared memory type from being forwarded

Implements [eclipse-uprotocol#30]
  • Loading branch information
brianeaton authored and PLeVasseur committed Aug 12, 2024
1 parent 15ffc8b commit f291e0b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion up-streamer/src/ustreamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use std::str;
use std::thread;
use subscription_cache::SubscriptionCache;
use up_rust::core::usubscription::{FetchSubscriptionsRequest, SubscriberInfo, USubscription};
use up_rust::{UCode, UListener, UMessage, UStatus, UTransport, UUIDBuilder, UUri};
use up_rust::{UCode, UListener, UMessage, UPayloadFormat, UStatus, UTransport, UUIDBuilder, UUri};

const USTREAMER_TAG: &str = "UStreamer:";
const USTREAMER_FN_NEW_TAG: &str = "new():";
Expand Down Expand Up @@ -916,6 +916,22 @@ impl UListener for ForwardingListener {
FORWARDING_LISTENER_FN_ON_RECEIVE_TAG,
&msg
);

if msg.attributes.payload_format.enum_value_or_default()
== UPayloadFormat::UPAYLOAD_FORMAT_SHM
{
debug!(
"{}:{}:{} Received message with type UPAYLOAD_FORMAT_SHM, \
which is not supported. A pointer to shared memory will not \
be usable on another device. UAttributes: {:#?}",
self.forwarding_id,
FORWARDING_LISTENER_TAG,
FORWARDING_LISTENER_FN_ON_RECEIVE_TAG,
&msg.attributes
);
return;
}

if let Err(e) = self.sender.send(Arc::new(msg)).await {
error!(
"{}:{}:{} Unable to send message to worker pool: {e:?}",
Expand Down

0 comments on commit f291e0b

Please sign in to comment.