Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 from cznic/master
Browse files Browse the repository at this point in the history
Fix errors II. (This time tested).
  • Loading branch information
karalabe committed Jan 29, 2015
2 parents f3db03b + abb38bd commit da046ac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions shootout/jnml/copy.go
Expand Up @@ -8,8 +8,6 @@ func Copy(dst io.Writer, src io.Reader, buffer int) (int64, error) {
const page = 1 << 12

w := make(chan []byte, 1000)
defer close(w)

r := make(chan interface{}, 1000)

go func() {
Expand Down Expand Up @@ -38,6 +36,7 @@ func Copy(dst io.Writer, src io.Reader, buffer int) (int64, error) {
case x := <-r:
switch x := x.(type) {
case error:
close(w)
return nn, x
case int:
buffer += x
Expand All @@ -49,6 +48,7 @@ func Copy(dst io.Writer, src io.Reader, buffer int) (int64, error) {
case x := <-r:
switch x := x.(type) {
case error:
close(w)
return nn, x
case int:
buffer += x
Expand All @@ -65,6 +65,7 @@ func Copy(dst io.Writer, src io.Reader, buffer int) (int64, error) {
}

if err != nil {
close(w)
if err == io.EOF {
for {
switch x := (<-r).(type) {
Expand Down

0 comments on commit da046ac

Please sign in to comment.