]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: always decref if setting deadline fails
authorIan Lance Taylor <iant@golang.org>
Wed, 18 Oct 2017 23:04:45 +0000 (16:04 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 19 Oct 2017 00:16:21 +0000 (00:16 +0000)
No test because at present it is never called in a way that fails.
When #22114 is implemented, failure will be possible. Not including this
change in that work because this change is separable and clearly correct.

Updates #22114

Change-Id: I81eb9eec8800e8082d918c0e5fb71282f538267e
Reviewed-on: https://go-review.googlesource.com/71751
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joe Tsai <joetsai@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/internal/poll/fd_poll_runtime.go

index bfbe3c7de46960e21fcfd91d3734246de19bb2a9..866f26f3fcf282f9eba0a9998e4e8d0d71ae325c 100644 (file)
@@ -147,11 +147,11 @@ func setDeadlineImpl(fd *FD, t time.Time, mode int) error {
        if err := fd.incref(); err != nil {
                return err
        }
+       defer fd.decref()
        if fd.pd.runtimeCtx == 0 {
                return errors.New("file type does not support deadlines")
        }
        runtime_pollSetDeadline(fd.pd.runtimeCtx, d, mode)
-       fd.decref()
        return nil
 }