Fix indefinite client hang after connection reset #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We discovered a problem in this library that causes the client to hang
indefinitely. This patch makes sure that the locking part
(
net.textproto.Pipeline.StopRequest
) is executed whenever the functionreturns.
Steps to reproduce:
beanstalkd
and keep the connection openTubeSet.Reserve(...)
TubeSet.Reserve(...)
. The expected error is:reserve-with-timeout: read tcp srcip:srcport->dstip:dstport: read: connection reset by peer
TubeSet.Reserve(...)
. The expected error is:reserve-with-timeout: write tcp srcip:srcport->dstip:dstport: write: broken pipe
After step 3,
t.Conn.cmd(...)
(intubeset.go:30
) is executed without error,because writes to a half-closed socket are accepted. Step 4, then, fails with
the error mentioned. In step 5, the write fails and
t.Conn.cmd(...)
returnsearly in
conn.go:76
.However,
c.c.StartRequest(r.id)
is not properly ended and this causes jobswith an
id
larger thanr.id
to wait indefinitely to be processed.Cc: @Minnozz
Fixes: #21