From 0f36b222f3f36e72e90d5330bdcb76a2c0e620ac Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Wed, 26 Mar 2014 15:46:02 -0700 Subject: [PATCH] beam/examples/beamsh: more useful debugging Docker-DCO-1.1-Signed-off-by: Solomon Hykes (github: shykes) --- beam/examples/beamsh/beamsh.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/beam/examples/beamsh/beamsh.go b/beam/examples/beamsh/beamsh.go index 837622d..58f404d 100644 --- a/beam/examples/beamsh/beamsh.go +++ b/beam/examples/beamsh/beamsh.go @@ -56,23 +56,25 @@ func main() { } } -func beamCopy(dst *net.UnixConn, src *net.UnixConn) error { +func beamCopy(dst *net.UnixConn, src *net.UnixConn) (int, error) { + var n int for { payload, attachment, err := beam.Receive(src) if err == io.EOF { - return nil + return n, nil } else if err != nil { - return err + return n, err } if err := beam.Send(dst, payload, attachment); err != nil { if attachment != nil { attachment.Close() } - return err + return n, err } + n++ } panic("impossibru!") - return nil + return n, nil } type Handler func([]string, *net.UnixConn, *net.UnixConn) @@ -165,7 +167,11 @@ func executeCommand(client *net.UnixConn, cmd *dockerscript.Command) error { }() go func() { Debugf("[%s] copy start...\n", strings.Join(cmd.Args, " ")) - beamCopy(client, outPub) + n, err := beamCopy(client, outPub) + if err != nil { + Fatal(err) + } + Debugf("[%s] copied %d messages\n", strings.Join(cmd.Args, " "), n) Debugf("[%s] copy done\n", strings.Join(cmd.Args, " ")) tasks.Done() }()