summaryrefslogtreecommitdiff
path: root/xdelta3/go/src/xdelta/rstream.go
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/go/src/xdelta/rstream.go')
-rw-r--r--xdelta3/go/src/xdelta/rstream.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/xdelta3/go/src/xdelta/rstream.go b/xdelta3/go/src/xdelta/rstream.go
index 7d205c6..9481f22 100644
--- a/xdelta3/go/src/xdelta/rstream.go
+++ b/xdelta3/go/src/xdelta/rstream.go
@@ -13,15 +13,15 @@ const (
13 13
14func (t *TestGroup) WriteRstreams(desc string, seed, offset, len int64, 14func (t *TestGroup) WriteRstreams(desc string, seed, offset, len int64,
15 src, tgt io.WriteCloser) { 15 src, tgt io.WriteCloser) {
16 t.Go("src-write:"+desc, func (g Goroutine) { 16 t.Go("src-write:"+desc, func (g *Goroutine) {
17 writeOne(g, seed, 0, len, src, false) 17 writeOne(g, seed, 0, len, src, false)
18 }) 18 })
19 t.Go("tgt-write:"+desc, func (g Goroutine) { 19 t.Go("tgt-write:"+desc, func (g *Goroutine) {
20 writeOne(g, seed, offset, len, tgt, true) 20 writeOne(g, seed, offset, len, tgt, true)
21 }) 21 })
22} 22}
23 23
24func writeOne(g Goroutine, seed, offset, len int64, stream io.WriteCloser, readall bool) { 24func writeOne(g *Goroutine, seed, offset, len int64, stream io.WriteCloser, readall bool) {
25 if !readall { 25 if !readall {
26 // Allow the source-read to fail or block until the process terminates. 26 // Allow the source-read to fail or block until the process terminates.
27 // This behavior is reserved for the decoder, which is not required to 27 // This behavior is reserved for the decoder, which is not required to
@@ -40,27 +40,23 @@ func writeOne(g Goroutine, seed, offset, len int64, stream io.WriteCloser, reada
40 len - offset, stream); err != nil { 40 len - offset, stream); err != nil {
41 g.Panic(err) 41 g.Panic(err)
42 } 42 }
43 fmt.Println(g, "closing", len)
44 if err := stream.Close(); err != nil { 43 if err := stream.Close(); err != nil {
45 g.Panic(err) 44 g.Panic(err)
46 } 45 }
47 g.OK() 46 g.OK()
48} 47}
49 48
50func writeRand(g Goroutine, r *rand.Rand, len int64, s io.Writer) error { 49func writeRand(g *Goroutine, r *rand.Rand, len int64, s io.Writer) error {
51 blk := make([]byte, blocksize) 50 blk := make([]byte, blocksize)
52 fmt.Println(g, "rstream", len)
53 for len > 0 { 51 for len > 0 {
54 fillRand(r, blk) 52 fillRand(r, blk)
55 c := blocksize 53 c := blocksize
56 if len < blocksize { 54 if len < blocksize {
57 c = int(len) 55 c = int(len)
58 } 56 }
59 fmt.Println(g, "writing...", c, s)
60 if _, err := s.Write(blk[0:c]); err != nil { 57 if _, err := s.Write(blk[0:c]); err != nil {
61 return err 58 return err
62 } 59 }
63 fmt.Println(g, "...written", c)
64 len -= int64(c) 60 len -= int64(c)
65 } 61 }
66 return nil 62 return nil