From c6da90ac63c66f24eba957787e210f817869e866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 26 Apr 2016 09:32:04 +0200 Subject: [PATCH] orb nuttx: fix threadding issue in uORB::DeviceNode::write same issue as in posix code: 64bit values are not atomic in general. --- src/modules/uORB/uORBDevices_nuttx.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/uORB/uORBDevices_nuttx.cpp b/src/modules/uORB/uORBDevices_nuttx.cpp index c39612f686..3e254da8c1 100644 --- a/src/modules/uORB/uORBDevices_nuttx.cpp +++ b/src/modules/uORB/uORBDevices_nuttx.cpp @@ -245,17 +245,18 @@ uORB::DeviceNode::write(struct file *filp, const char *buffer, size_t buflen) /* Perform an atomic copy. */ irqstate_t flags = irqsave(); memcpy(_data, buffer, _meta->o_size); - irqrestore(flags); /* update the timestamp and generation count */ _last_update = hrt_absolute_time(); _generation++; + _published = true; + + irqrestore(flags); + /* notify any poll waiters */ poll_notify(POLLIN); - _published = true; - return _meta->o_size; }