Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/net/lib/libshmif Fix hopefully last off-by-one: if ...



details:   https://anonhg.NetBSD.org/src/rev/fa8642027e25
branches:  trunk
changeset: 757172:fa8642027e25
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Aug 17 12:59:53 2010 +0000

description:
Fix hopefully last off-by-one: if we fill the bus, we must also
advance the "first" pointer.  This problem triggered only if the
bus was filled in the first round, since the first pointer is at
the end-of-bus only for the bootstrap round.

diffstat:

 sys/rump/net/lib/libshmif/shmif_busops.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r a9d8043d21a7 -r fa8642027e25 sys/rump/net/lib/libshmif/shmif_busops.c
--- a/sys/rump/net/lib/libshmif/shmif_busops.c  Tue Aug 17 12:04:34 2010 +0000
+++ b/sys/rump/net/lib/libshmif/shmif_busops.c  Tue Aug 17 12:59:53 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: shmif_busops.c,v 1.6 2010/08/17 11:35:23 pooka Exp $   */
+/*     $NetBSD: shmif_busops.c,v 1.7 2010/08/17 12:59:53 pooka Exp $   */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: shmif_busops.c,v 1.6 2010/08/17 11:35:23 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: shmif_busops.c,v 1.7 2010/08/17 12:59:53 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -93,20 +93,23 @@
        bool *wrap)
 {
        size_t chunk;
+       bool filledbus;
 
        KASSERT(len < (BUSMEM_DATASIZE/2) && off <= BUSMEM_DATASIZE);
 
        chunk = MIN(len, BUSMEM_DATASIZE - off);
        len -= chunk;
+       filledbus = (off+chunk == BUSMEM_DATASIZE);
 
-       shmif_advancefirst(busmem, off, chunk + (len ? 1 : 0));
+       shmif_advancefirst(busmem, off, chunk + (filledbus ? 1 : 0));
 
        memcpy(busmem->shm_data + off, data, chunk);
 
        DPRINTF(("buswrite: wrote %d bytes to %d", chunk, off));
 
-       if (off + chunk == BUSMEM_DATASIZE)
+       if (filledbus) {
                *wrap = true;
+       }
 
        if (len == 0) {
                DPRINTF(("\n"));



Home | Main Index | Thread Index | Old Index