From 6610dac99c6e7370aa0a1d6d0521e301533dc61e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 23 Aug 2007 11:10:58 -0400 Subject: venti: avoid race in mirrorarenas (Michael Kaminsky) --- src/cmd/venti/srv/mirrorarenas.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/cmd/venti') diff --git a/src/cmd/venti/srv/mirrorarenas.c b/src/cmd/venti/srv/mirrorarenas.c index b16472bb..8b72f1a5 100644 --- a/src/cmd/venti/srv/mirrorarenas.c +++ b/src/cmd/venti/srv/mirrorarenas.c @@ -93,6 +93,7 @@ ewritepart(Part *p, u64int offset, u8int *buf, u32int count) * src with writing dst during copy. This is an easy factor of two * (almost) in performance. */ +static Write wsync; static void writeproc(void *v) { @@ -100,7 +101,7 @@ writeproc(void *v) USED(v); while((w = recvp(writechan)) != nil){ - if(w->n == 0) + if(w == &wsync) continue; if(ewritepart(dst, w->o, w->p, w->n) < 0) w->error = 1; @@ -147,11 +148,7 @@ copy(uvlong start, uvlong end, char *what, DigestState *ds) /* * wait for queued write to finish */ - w[i].p = nil; - w[i].o = 0; - w[i].n = 0; - w[i].error = 0; - sendp(writechan, &w[i]); + sendp(writechan, &wsync); i = 1-i; if(w[i].error) return -1; -- cgit v1.2.3