Hello adg (cc: golang-dev@googlegroups.com), I'd like you to review this change.
LGTM On 16 September 2010 13:57, <r@golang.org> wrote: > Reviewers: adg, > > Message: > Hello adg (cc: golang-dev@googlegroups.com), > > I'd like you to review this change. > > > Description: > netchan: fix bug for imported send. > Also add a bit of debugging and sanitation code. > Fixes issue 769. > > Please review this at http://codereview.appspot.com/2206042/ > > Affected files: > M src/pkg/netchan/common.go > M src/pkg/netchan/export.go > M src/pkg/netchan/import.go > > > Index: src/pkg/netchan/common.go > =================================================================== > --- a/src/pkg/netchan/common.go > +++ b/src/pkg/netchan/common.go > @@ -21,6 +21,16 @@ > Send > ) > > +func (dir Dir) String() string { > + switch dir { > + case Recv: > + return "Recv" > + case Send: > + return "Send" > + } > + return "???" > +} > + > // Payload types > const ( > payRequest = iota // request structure follows > Index: src/pkg/netchan/export.go > =================================================================== > --- a/src/pkg/netchan/export.go > +++ b/src/pkg/netchan/export.go > @@ -19,7 +19,7 @@ > */ > package netchan > > -// BUG: can't use range clause to receive when using ImportNValues with N > non-zero. > +// BUG: can't use range clause to receive when using ImportNValues to limit > the count. > > import ( > "log" > @@ -94,6 +94,7 @@ > reqValue := reflect.NewValue(req) > error := new(error) > for { > + *hdr = header{} > if err := client.decode(hdrValue); err != nil { > log.Stderr("error decoding client header:", err) > break > Index: src/pkg/netchan/import.go > =================================================================== > --- a/src/pkg/netchan/import.go > +++ b/src/pkg/netchan/import.go > @@ -64,6 +64,7 @@ > err := new(error) > errValue := reflect.NewValue(err) > for { > + *hdr = header{} > if e := imp.decode(hdrValue); e != nil { > log.Stderr("importer header:", e) > imp.shutdown() > @@ -152,7 +153,7 @@ > } > if dir == Send { > go func() { > - for i := 0; n == 0 || i < n; i++ { > + for i := 0; n == -1 || i < n; i++ { > val := ch.Recv() > if err := imp.encode(hdr, payData, > val.Interface()); err != nil { > log.Stderr("error encoding client > response:", err) > > >
*** Submitted as http://code.google.com/p/go/source/detail?r=841ebdcb43b2 *** netchan: fix bug for imported send. Also add a bit of debugging and sanitation code. Fixes issue 769. R=adg CC=golang-dev http://codereview.appspot.com/2206042