Module: xenomai-2.5
Branch: master
Commit: a259751ec439aae9980d2596004db4ec360888c3
URL:    
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=a259751ec439aae9980d2596004db4ec360888c3

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Mar 29 10:47:09 2010 +0200

native/buffer: reset buffer descriptor upon r/w preemption

In order to perform data copy while reading/writing data from/to a
buffer descriptor in a lockless manner, we rely on a control token for
detecting any preemption that shall lead to invalidating the current
buffer, before redoing the data acquisition.

Make sure to reset the buffer descriptor appropriately, before redoing
the acquisition, so that the old contents are discarded.

---

 ksrc/skins/native/buffer.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ksrc/skins/native/buffer.c b/ksrc/skins/native/buffer.c
index 2d364bb..8aca559 100644
--- a/ksrc/skins/native/buffer.c
+++ b/ksrc/skins/native/buffer.c
@@ -400,8 +400,10 @@ redo:
                         * the message, we have to resend the whole
                         * thing.
                         */
-                       if (bf->wrtoken != wrtoken)
+                       if (bf->wrtoken != wrtoken) {
+                               xnbufd_reset(bufd);
                                goto redo;
+                       }
 
                        wroff = (wroff + n) % bf->bufsz;
                        rbytes -= n;
@@ -557,8 +559,10 @@ redo:
                         * the message, we have to re-read the whole
                         * thing.
                         */
-                       if (bf->rdtoken != rdtoken)
+                       if (bf->rdtoken != rdtoken) {
+                               xnbufd_reset(bufd);
                                goto redo;
+                       }
 
                        rdoff = (rdoff + n) % bf->bufsz;
                        rbytes -= n;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to