Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(631)

Issue 5571056: code review 5571056: net: make WriteTo fail when UDPConn is already connected (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 2 months ago by mikio
Modified:
4 years, 3 months ago
Reviewers:
hit.zhangjie, rsc
CC:
rsc, golang-dev
Visibility:
Public.

Description

net: make WriteTo fail when UDPConn is already connected Fixes issue 2773.

Patch Set 1 : diff -r cd529ae19b47 https://go.googlecode.com/hg/ #

Patch Set 2 : diff -r 5f4913cff1ef https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 49bf7083ea05 https://go.googlecode.com/hg/ #

Total comments: 2

Patch Set 4 : diff -r 7d32596163d7 https://go.googlecode.com/hg/ #

Patch Set 5 : diff -r 47fe3b1af323 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+113 lines, -17 lines) Patch
M src/pkg/net/fd.go View 1 chunk +10 lines, -9 lines 0 comments Download
M src/pkg/net/fd_windows.go View 1 chunk +9 lines, -8 lines 0 comments Download
M src/pkg/net/sock.go View 1 chunk +1 line, -0 lines 0 comments Download
A src/pkg/net/udp_test.go View 1 2 3 1 chunk +87 lines, -0 lines 0 comments Download
M src/pkg/net/udpsock_posix.go View 1 2 3 2 chunks +6 lines, -0 lines 0 comments Download

Messages

Total messages: 10
mikio
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 2 months ago (2012-01-25 01:51:04 UTC) #1
mikio
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 2 months ago (2012-01-25 02:07:08 UTC) #2
rsc
http://codereview.appspot.com/5571056/diff/1015/src/pkg/net/udpsock_posix.go File src/pkg/net/udpsock_posix.go (right): http://codereview.appspot.com/5571056/diff/1015/src/pkg/net/udpsock_posix.go#newcode190 src/pkg/net/udpsock_posix.go:190: return c.fd.Write(b) Is this necessary? I would much rather ...
12 years, 2 months ago (2012-01-25 22:09:39 UTC) #3
mikio
http://codereview.appspot.com/5571056/diff/1015/src/pkg/net/udpsock_posix.go File src/pkg/net/udpsock_posix.go (right): http://codereview.appspot.com/5571056/diff/1015/src/pkg/net/udpsock_posix.go#newcode190 src/pkg/net/udpsock_posix.go:190: return c.fd.Write(b) > I would much rather have what ...
12 years, 2 months ago (2012-01-26 01:52:38 UTC) #4
mikio
Hello rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 2 months ago (2012-01-26 01:53:40 UTC) #5
rsc
LGTM
12 years, 2 months ago (2012-01-26 15:33:23 UTC) #6
mikio
*** Submitted as http://code.google.com/p/go/source/detail?r=8397cd2d5ae9 *** net: make WriteTo fail when UDPConn is already connected Fixes ...
12 years, 2 months ago (2012-01-26 16:31:48 UTC) #7
hit.zhangjie
On 2012/01/26 16:31:48, mikio wrote: > *** Submitted as http://code.google.com/p/go/source/detail?r=8397cd2d5ae9 *** > > net: make ...
4 years, 3 months ago (2019-12-05 03:48:10 UTC) #8
hit.zhangjie
On 2019/12/05 03:48:10, hit.zhangjie wrote: > On 2012/01/26 16:31:48, mikio wrote: > > *** Submitted ...
4 years, 3 months ago (2019-12-05 04:00:17 UTC) #9
hit.zhangjie
4 years, 3 months ago (2019-12-05 04:03:04 UTC) #10
Message was sent while issue was closed.
On 2019/12/05 03:48:10, hit.zhangjie wrote:
> On 2012/01/26 16:31:48, mikio wrote:
> > *** Submitted as http://code.google.com/p/go/source/detail?r=8397cd2d5ae9
***
> > 
> > net: make WriteTo fail when UDPConn is already connected
> > 
> > Fixes issue 2773.
> > 
> > R=rsc
> > CC=golang-dev
> > http://codereview.appspot.com/5571056
> 
> Hi, I have a question about `make WriteTo fail when udpconn is already
> connected` in `src/pkg/net/udpsock_posix.go`.
> 
> ```go
> func (c *UDPConn) writeMsg(b, oob []byte, addr *UDPAddr) (n, oobn int, err
> error) {
> 
> 
> 	if c.fd.isConnected && addr != nil {
> 		return 0, 0, ErrWriteToConnected  // here, why not check addr before return
an
> error ErrWriteToConnected ?
> 	}
> 	if !c.fd.isConnected && addr == nil {
> 		return 0, 0, errMissingAddress
> 	}
> 	sa, err := addr.sockaddr(c.fd.family)
> 	if err != nil {
> 		return 0, 0, err
> 	}
> 	return c.fd.writeMsg(b, oob, sa)
> }
> ```
> 
> Why not check whether param `addr` is equal to peer address of this connected
> udpconn before return an error ErrWriteToConnected ?
> Is it for performance? This error makes me confused.

Sorry, I send it multiple times, my bad. 
And I checked c functionn `sendto`, `UDPConn.WriteTo` behaves the same as
`sendto`. I misunderstood its behavior.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b