Commit 381ab58e authored by Rob Pike's avatar Rob Pike

netchan: fix bug for imported send.

Also add a bit of debugging and sanitation code.
Fixes #769.

R=adg
CC=golang-dev
https://golang.org/cl/2206042
parent 5667d825
......@@ -21,6 +21,16 @@ const (
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
......
......@@ -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 @@ func (client *expClient) run() {
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
......
......@@ -64,6 +64,7 @@ func (imp *Importer) run() {
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 @@ func (imp *Importer) ImportNValues(name string, chT interface{}, dir Dir, n int)
}
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment