Skip to content

bufio: no way to recover from temporary errors #1934

@gjemiller

Description

@gjemiller
Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1.  Use bufio to wrap a socket (as a reader)
2.  Call read when there is no data avialable on the socket
3.  Never get data from the socket again


Which compiler are you using (5g, 6g, 8g, gccgo)?
All

Which operating system are you using?
Linux

Which revision are you using?  (hg identify)
bece9e7a644b tip

Please provide any additional information below.
In bufio.Read() ( http://golang.org/src/pkg/bufio/bufio.go?s=3281:3334#L124 ), if the
buffer is empty (b.w == b.r) and a previous read has resulted in an error (b.err != nil)
that it will never again issue a Read to the underlying reader.

This is a problem in the case of "temporary" errors like that issued by a read
to a socket with no data avialable.

Two possible remedies:  provide a bufio.ResetError or test inside the Read method for
the temporariness of the error (which might not be desirable, given that there's no
interface defining the semantics of the Temporary method that occurs on various error
types).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions