Module Name:    src
Committed By:   pooka
Date:           Tue Aug 17 12:59:53 UTC 2010

Modified Files:
        src/sys/rump/net/lib/libshmif: shmif_busops.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/rump/net/lib/libshmif/shmif_busops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/net/lib/libshmif/shmif_busops.c
diff -u src/sys/rump/net/lib/libshmif/shmif_busops.c:1.6 src/sys/rump/net/lib/libshmif/shmif_busops.c:1.7
--- src/sys/rump/net/lib/libshmif/shmif_busops.c:1.6	Tue Aug 17 11:35:23 2010
+++ src/sys/rump/net/lib/libshmif/shmif_busops.c	Tue Aug 17 12:59:53 2010
@@ -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"));

Reply via email to