Skip to content

Commit a474791

Browse files
committed
Set MU on key fields only if explicitly marked MU
Needed to work around bugs in RTI's XCDR1 mutable encoding implementation. Signed-off-by: Erik Boasson <[email protected]>
1 parent 3711b84 commit a474791

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cyclonedds/idl/_machinery.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,11 @@ def serialize(self, buffer, value, serialize_kind=SerializeKind.DataSample, key_
11231123
# TODO: use compact variant when member id and the max serialized size of the type are small enough
11241124
buffer.write('H', 2, XCDR1.PL_SHORT_PID_EXTENDED | XCDR1.PL_SHORT_FLAG_MU)
11251125
buffer.write('H', 2, XCDR1.PL_SHORT_PID_EXT_LEN)
1126-
mu_flag = (1 if mutablemember.must_understand or m_key_enabled != KeyEnabled.Never else 0) << 30
1126+
# It appears RTI can't handle "must understand" on key fields, even though
1127+
# XTypes 1.3 requires it. This should read:
1128+
# mu_flag = (1 if mutablemember.must_understand or
1129+
# m_key_enabled != KeyEnabled.Never else 0) << 30
1130+
mu_flag = (1 if mutablemember.must_understand else 0) << 30
11271131
buffer.write('I', 4, mu_flag | mutablemember.memberid)
11281132
assert mutablemember.lentype == LenType.NextIntLen
11291133

cyclonedds/idl/_xt_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ def _xt_member_flag(cls, entity: Any, name: str, _type: type) -> xt.MemberFlag:
10381038
if _is_optional(_type):
10391039
flag.IS_OPTIONAL = True
10401040

1041-
if annotations.get("must_understand", False) or annotations.get("key", False) or in_keylist:
1041+
if annotations.get("must_understand", False):
10421042
flag.IS_MUST_UNDERSTAND = True
10431043

10441044
if annotations.get("key", False) or in_keylist:

0 commit comments

Comments
 (0)