From c2fbfedc830ded482b1966ef542f8af5f0eaee85 Mon Sep 17 00:00:00 2001 From: pooka Date: Tue, 17 Aug 2010 12:59:53 +0000 Subject: [PATCH] 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. --- sys/rump/net/lib/libshmif/shmif_busops.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/rump/net/lib/libshmif/shmif_busops.c b/sys/rump/net/lib/libshmif/shmif_busops.c index 3821df5797ac..2d292f1d6dc7 100644 --- a/sys/rump/net/lib/libshmif/shmif_busops.c +++ b/sys/rump/net/lib/libshmif/shmif_busops.c @@ -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 -__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 #include @@ -93,20 +93,23 @@ shmif_buswrite(struct shmif_mem *busmem, uint32_t off, void *data, size_t len, 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"));