Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesn't handle connection close #14

Closed
GoogleCodeExporter opened this issue May 15, 2015 · 4 comments
Closed

doesn't handle connection close #14

GoogleCodeExporter opened this issue May 15, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

1. Start a server (I tried with examples ufs.go)

2. Start client which reads a (big) file, like

    file, err := c.FOpen(name, p.OREAD)
  if err != nil {
        return nil, os.NewError(err.String())
  }
    defer file.Close()

    buf := make([]byte, 8192)
  for {
        fmt.Printf("reading chunk\n")
    n, err := file.Read(buf)
    if err != nil {
            return nil, os.NewError(err.String())
    }

    if n == 0 {
        break
    }

        dest.Write(buf[0:n])
  }

3. Kill the server in the middle of the write


The reader will be stuck during read and never resume.


Original issue reported on code.google.com by mmikuli...@gmail.com on 31 May 2011 at 1:32

@GoogleCodeExporter
Copy link
Author

After some debugging I found out that the file.Read call returns correcty an 
EOF error, but my client doesn't return because it's blocked on "defer 
file.Close()".

I believe it's a bug and that file.Close() should be able to complete also in 
this circumstance.

Original comment by mmikuli...@gmail.com on 31 May 2011 at 2:21

@GoogleCodeExporter
Copy link
Author

So basically what happens is that after a connection is broken every next 
attempt to send rpc messages will block.

This happens because the "Send" goroutine exits without closing his acceptor 
channel:

func (clnt *Clnt) send() {
    for {
        select {
        case <-clnt.done:
            return
...

Attaching a patch.

Original comment by mmikuli...@gmail.com on 31 May 2011 at 3:07

@GoogleCodeExporter
Copy link
Author

Original comment by mmikuli...@gmail.com on 31 May 2011 at 3:08

Attachments:

@GoogleCodeExporter
Copy link
Author

Thanks for catching this.

I think there is much simpler fix, just pushed it. Can you please check if it 
fixes the bug for you?

Thanks,
    Lucho

Original comment by lion...@gmail.com on 31 May 2011 at 7:56

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant