FAQ
Reviewers: bradfitz, mikio, dvyukov,

Message:
Hello bradfitz@golang.org, mikioh.mikioh@gmail.com, dvyukov@google.com
(cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/go


Description:
net: never return -1 bytes read from netFD.Read

If the a network read would block, and a packet arrived just before the
timeout expired, then the number of bytes from the previous (blocking)
read, -1, would be returned.

This change restores the previous logic, where n would be
unconditionally set to 0 if err != nil, but was skipped due to a change
in CL 6851096.

The test for this change is CL 6851061.

Please review this at http://codereview.appspot.com/6852085/

Affected files:
M src/pkg/net/fd_unix.go


Index: src/pkg/net/fd_unix.go
===================================================================
--- a/src/pkg/net/fd_unix.go
+++ b/src/pkg/net/fd_unix.go
@@ -431,6 +431,7 @@
}
n, err = syscall.Read(int(fd.sysfd), p)
if err == syscall.EAGAIN {
+ n = 0
err = errTimeout
if fd.rdeadline >= 0 {
if err = fd.pollServer.WaitRead(fd); err == nil {
@@ -467,6 +468,7 @@
}
n, sa, err = syscall.Recvfrom(fd.sysfd, p, 0)
if err == syscall.EAGAIN {
+ n = 0
err = errTimeout
if fd.rdeadline >= 0 {
if err = fd.pollServer.WaitRead(fd); err == nil {
@@ -501,6 +503,7 @@
}
n, oobn, flags, sa, err = syscall.Recvmsg(fd.sysfd, p, oob, 0)
if err == syscall.EAGAIN {
+ n = 0
err = errTimeout
if fd.rdeadline >= 0 {
if err = fd.pollServer.WaitRead(fd); err == nil {

Search Discussions

  • Rsc at Nov 25, 2012 at 4:18 pm
  • Brad Fitzpatrick at Nov 25, 2012 at 5:19 pm
    LGTM

    nice, thanks!

    On Sun, Nov 25, 2012 at 3:43 AM, wrote:

    Reviewers: bradfitz, mikio, dvyukov,

    Message:
    Hello bradfitz@golang.org, mikioh.mikioh@gmail.com, dvyukov@google.com
    (cc: golang-dev@googlegroups.com),

    I'd like you to review this change to
    https://code.google.com/p/go


    Description:
    net: never return -1 bytes read from netFD.Read

    If the a network read would block, and a packet arrived just before the
    timeout expired, then the number of bytes from the previous (blocking)
    read, -1, would be returned.

    This change restores the previous logic, where n would be
    unconditionally set to 0 if err != nil, but was skipped due to a change
    in CL 6851096.

    The test for this change is CL 6851061.

    Please review this at http://codereview.appspot.com/**6852085/<http://codereview.appspot.com/6852085/>

    Affected files:
    M src/pkg/net/fd_unix.go


    Index: src/pkg/net/fd_unix.go
    ==============================**==============================**=======
    --- a/src/pkg/net/fd_unix.go
    +++ b/src/pkg/net/fd_unix.go
    @@ -431,6 +431,7 @@
    }
    n, err = syscall.Read(int(fd.sysfd), p)
    if err == syscall.EAGAIN {
    + n = 0
    err = errTimeout
    if fd.rdeadline >= 0 {
    if err = fd.pollServer.WaitRead(fd); err
    == nil {
    @@ -467,6 +468,7 @@
    }
    n, sa, err = syscall.Recvfrom(fd.sysfd, p, 0)
    if err == syscall.EAGAIN {
    + n = 0
    err = errTimeout
    if fd.rdeadline >= 0 {
    if err = fd.pollServer.WaitRead(fd); err
    == nil {
    @@ -501,6 +503,7 @@
    }
    n, oobn, flags, sa, err = syscall.Recvmsg(fd.sysfd, p,
    oob, 0)
    if err == syscall.EAGAIN {
    + n = 0
    err = errTimeout
    if fd.rdeadline >= 0 {
    if err = fd.pollServer.WaitRead(fd); err
    == nil {

  • Dave at Nov 25, 2012 at 11:59 pm
    *** Submitted as
    http://code.google.com/p/go/source/detail?r=03a6b8c9c396 ***

    net: never return -1 bytes read from netFD.Read

    If the a network read would block, and a packet arrived just before the
    timeout expired, then the number of bytes from the previous (blocking)
    read, -1, would be returned.

    This change restores the previous logic, where n would be
    unconditionally set to 0 if err != nil, but was skipped due to a change
    in CL 6851096.

    The test for this change is CL 6851061.

    R=bradfitz, mikioh.mikioh, dvyukov, rsc
    CC=golang-dev
    http://codereview.appspot.com/6852085


    http://codereview.appspot.com/6852085/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedNov 25, '12 at 11:43a
activeNov 25, '12 at 11:59p
posts4
users3
websitegolang.org

3 users in discussion

Dave: 2 posts Rsc: 1 post Brad Fitzpatrick: 1 post

People

Translate

site design / logo © 2022 Grokbase