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

compress/gzip: SetReadDeadline take no effect when wrapping a net.Conn with Reader #28052

Closed
xxxsen opened this issue Oct 6, 2018 · 2 comments
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@xxxsen
Copy link

xxxsen commented Oct 6, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9.2 windows/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\GoProj\wcf\wcf;D:\GoPath
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

What did you do?

I wrap a network connection with gzip reader and SetReadDeadline for it, but it take no effect when an timeout error occur

code in gunzip.go

func (z *Reader) Read(p []byte) (n int, err error) {
	if z.err != nil {
		return 0, z.err    //** when an error occur, it has no way to go next **
	}

	n, z.err = z.decompressor.Read(p)    //** it may return a timeout error when the reader wrap a network connection **
	z.digest = crc32.Update(z.digest, crc32.IEEETable, p[:n])
	z.size += uint32(n)
	if z.err != io.EOF {
		// In the normal case we return here.
		return n, z.err
	}
        ....

What did you expect to see?

SetReadDeadline take effect and I could retry Read operation when timeout occur

What did you see instead?

SetReadDeadline make no effect

@agnivade agnivade changed the title SetReadDeadline take no effect when use gzip reader compress/gzip: SetReadDeadline take no effect when wrapping a net.Conn with Reader Oct 7, 2018
@agnivade agnivade added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 7, 2018
@agnivade agnivade added this to the Unplanned milestone Oct 7, 2018
@agnivade
Copy link
Contributor

agnivade commented Oct 7, 2018

Thanks. Interesting scenario.

/cc @dsnet

@dsnet
Copy link
Member

dsnet commented Feb 5, 2019

This problem doesn't seem specific to compress/gzip, but any wrapping reader. Most of the io.Reader implementations in the standard library are sticky about read errors. It seems that there needs to be a more general solution where certain Read errors are recognized as non-fatal (and also leaves the reader in a consistent state).

I should also note that a generalized solution should also think about how timeout errors on write are handled (since the generalized problem applies to both reading and writing).

@dsnet dsnet removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 5, 2019
@seankhliao seankhliao added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Aug 20, 2022
@xxxsen xxxsen closed this as completed Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

4 participants