Thoughts? I don't entirely like how many parameters the internal functions socket and internetSocket take, ...
11 years, 5 months ago
(2012-10-29 12:54:17 UTC)
#2
Thoughts?
I don't entirely like how many parameters the internal functions socket
and internetSocket take, but they were already gross, and it's private, so
I don't mind too much.
I toyed with keeping the parameter counts the same but taking advantage of
raddr being an inteface type (syscall.Sockaddr) and instead just shoving
through the deadline in an wider runtime-asserted interface type (e.g.
deadlineSockaddr), but that was too clever and hard to follow.
This way at least is explicit.
If this looks okay, I'll finish it (not operating systems and socket types).
On Mon, Oct 29, 2012 at 1:50 PM, <bradfitz@golang.org> wrote:
> Reviewers: golang-dev_googlegroups.com,
>
> Message:
> Hello golang-dev@googlegroups.com,
>
> I'd like you to review this change to
> https://go.googlecode.com/hg/
>
>
> Description:
> net: close fds eagerly in DialTimeout
>
> WIP FOR DISCUSSION; THIS VERSION NOT FOR SUBMISSION
>
> Integrates with the pollserver now.
>
> Only currently tested on Linux and I've only plumbed through
> TCP for now. The rest will be done before submission, as well
> as using the deadline for DNS resolution in DialTimeout.
>
> Fixes issue 2631
>
> Please review this at
http://codereview.appspot.com/**6815049/<http://codereview.appspot.com/6815049/>
>
> Affected files:
> M src/pkg/net/dial.go
> M src/pkg/net/dial_test.go
> M src/pkg/net/iprawsock_posix.go
> M src/pkg/net/ipsock_posix.go
> M src/pkg/net/sock_posix.go
> M src/pkg/net/tcpsock_posix.go
> M src/pkg/net/udpsock_posix.go
> M src/pkg/net/unixsock_posix.go
>
>
>
On Mon, Oct 29, 2012 at 5:54 AM, Brad Fitzpatrick <bradfitz@golang.org> wrote: > Thoughts? > ...
11 years, 5 months ago
(2012-10-29 16:36:07 UTC)
#4
On Mon, Oct 29, 2012 at 5:54 AM, Brad Fitzpatrick <bradfitz@golang.org> wrote:
> Thoughts?
>
> I don't entirely like how many parameters the internal functions socket and
> internetSocket take, but they were already gross, and it's private, so I
> don't mind too much.
>
> I toyed with keeping the parameter counts the same but taking advantage of
> raddr being an inteface type (syscall.Sockaddr) and instead just shoving
> through the deadline in an wider runtime-asserted interface type (e.g.
> deadlineSockaddr), but that was too clever and hard to follow.
>
> This way at least is explicit.
>
> If this looks okay, I'll finish it (not operating systems and socket types).
Looks reasonable to me.
Ian
On Mon, Oct 29, 2012 at 3:32 PM, <paul@vanbrouwershaven.com> wrote: > I tested DialTimeout with ...
11 years, 5 months ago
(2012-10-29 16:39:03 UTC)
#5
On Mon, Oct 29, 2012 at 3:32 PM, <paul@vanbrouwershaven.com> wrote:
> I tested DialTimeout with this patch applied but it does not release the
> file descriptor nor the tcp session when connecting to a non existing IP
> address.
>
It shouldn't matter whether it exists or not.
My tests pass with the fix and fail without the fix, so I fixed something.
But adding some debug prints, I'm not seeing the explicit socket close I
expected, so something's still missing. I bet the finalizers are closing
my sockets, which might explain why my tests pass but your single fd test
fails.
I'll look into it more and expand the tests.
On Mon, Oct 29, 2012 at 3:32 PM, <paul@vanbrouwershaven.com> wrote: > I tested DialTimeout with ...
11 years, 5 months ago
(2012-10-30 17:16:24 UTC)
#6
On Mon, Oct 29, 2012 at 3:32 PM, <paul@vanbrouwershaven.com> wrote:
> I tested DialTimeout with this patch applied but it does not release the
> file descriptor nor the tcp session when connecting to a non existing IP
> address.
>
I found the problem. Thanks for pointing it out.
I tested this code and it has passed all my initial tests! Thanks for all ...
11 years, 5 months ago
(2012-10-31 13:46:50 UTC)
#11
I tested this code and it has passed all my initial tests! Thanks for all the
hard work I'm really happy that this one is fixed!
Now it becomes the challenge to apply this same logic to DialTCP. Are there any
plans to create a DialTCPTimeout?
On 2012/10/31 11:01:31, bradfitz wrote:
> This is ready for review now.
>
> On Wed, Oct 31, 2012 at 12:01 PM, <mailto:bradfitz@golang.org> wrote:
>
> > Hello mailto:golang-dev@googlegroups.com, mailto:paul@vanbrouwershaven.com,
> > mailto:iant@google.com, mailto:adg@golang.org (cc:
mailto:golang-dev@googlegroups.com),
> >
> > Please take another look.
> >
> >
> >
>
http://codereview.appspot.com/**6815049/%3Chttp://codereview.appspot.com/6815...>
> >
That would be one line of code but continues an API proliferation precedent. Can't you ...
11 years, 5 months ago
(2012-10-31 13:51:51 UTC)
#12
That would be one line of code but continues an API proliferation
precedent. Can't you just use DialTimeout or do you need to set the local
address?
On Oct 31, 2012 2:46 PM, <paul@vanbrouwershaven.com> wrote:
> I tested this code and it has passed all my initial tests! Thanks for
> all the hard work I'm really happy that this one is fixed!
>
> Now it becomes the challenge to apply this same logic to DialTCP. Are
> there any plans to create a DialTCPTimeout?
>
> On 2012/10/31 11:01:31, bradfitz wrote:
>
>> This is ready for review now.
>>
>
> On Wed, Oct 31, 2012 at 12:01 PM, <mailto:bradfitz@golang.org> wrote:
>>
>
> > Hello mailto:golang-dev@**googlegroups.com<golang-dev@googlegroups.com>
>> ,
>>
> mailto:paul@vanbrouwershaven.**com <paul@vanbrouwershaven.com>,
>
>> > mailto:iant@google.com, mailto:adg@golang.org (cc:
>>
> mailto:golang-dev@**googlegroups.com <golang-dev@googlegroups.com>),
>
>> >
>> > Please take another look.
>> >
>> >
>> >
>>
>
> http://codereview.appspot.com/****6815049/%3Chttp://**
>
codereview.appspot.com/**6815049/<http://codereview.appspot.com/**6815049/%3Chttp://codereview.appspot.com/6815049/>
> >
>
>> >
>>
>
>
>
https://codereview.appspot.**com/6815049/<https://codereview.appspot.com/6815...
>
Unfortunately, I need to set the local address which can only be done with DialTCP ...
11 years, 5 months ago
(2012-10-31 13:59:45 UTC)
#13
Unfortunately, I need to set the local address which can only be done with
DialTCP for now.
On 2012/10/31 13:51:51, bradfitz wrote:
> That would be one line of code but continues an API proliferation
> precedent. Can't you just use DialTimeout or do you need to set the local
> address?
The best way to implement this would be by using a setter as it's an ...
11 years, 5 months ago
(2012-10-31 15:12:37 UTC)
#14
The best way to implement this would be by using a setter as it's an infrequent
used parameter. I haven't seen setters on GO, so this may not be an option?
To continue testing on a broader scale I implemented a temporary DialTCPTimeout
function in src/pkg/net/dial.go (see below) and till now the patch it's exactly
doing what it should do!
The number of fd / SYN_SENT connections is dropped exactly to the number of
concurrent sessions.
--------------------
// DialTCPTimeout acts like DialTCP but takes a timeout.
// The timeout includes name resolution, if required.
func DialTCPTimeout(net, laddr, raddr string, timeout time.Duration) (Conn,
error) {
deadline := time.Now().Add(timeout)
laddri, err := ResolveTCPAddr("tcp", laddr)
if err != nil {
return nil, err
}
raddri, err := ResolveTCPAddr("tcp", raddr)
if err != nil {
return nil, err
}
return dialTCP(net, laddri, raddri, deadline)
}
On Wed, Oct 31, 2012 at 4:12 PM, <paul@vanbrouwershaven.com> wrote: > The best way to ...
11 years, 5 months ago
(2012-10-31 15:14:39 UTC)
#15
On Wed, Oct 31, 2012 at 4:12 PM, <paul@vanbrouwershaven.com> wrote:
> The best way to implement this would be by using a setter as it's an
> infrequent used parameter. I haven't seen setters on GO, so this may not
> be an option?
>
See API discussion at the bottom of semi-related
http://code.google.com/p/go/issues/detail?id=3610
I get and error when applying patch set 7, applying the failed patch by hand ...
11 years, 5 months ago
(2012-11-08 07:48:29 UTC)
#20
I get and error when applying patch set 7, applying the failed patch by hand
does not solve all problems.
Hunk #1 succeeded at 162 (offset -1 lines).
Hunk #2 succeeded at 187 (offset -1 lines).
Hunk #3 succeeded at 332 (offset 4 lines).
patching file src/pkg/net/iprawsock.go
patching file src/pkg/net/iprawsock_plan9.go
patching file src/pkg/net/iprawsock_posix.go
patching file src/pkg/net/ipsock.go
Hunk #1 FAILED at 6.
Hunk #2 succeeded at 103 (offset 5 lines).
Hunk #3 succeeded at 122 (offset 5 lines).
1 out of 3 hunks FAILED -- saving rejects to file src/pkg/net/ipsock.go.rej
------------------------------------------------------------------------------
--- src/pkg/net/ipsock.go
+++ src/pkg/net/ipsock.go
@@ -6,6 +6,8 @@
package net
+import "time"
+
var supportsIPv6, supportsIPv4map = probeIPv6Stack()
func firstFavoriteAddr(filter func(IP) IP, addrs []string) (addr IP) {
------------------------------------------------------------------------------
Adding 'import "time"' to 'src/pkg/net/ipsock.go' will no solve the whole
problem. Running all.bash causes the following error:
# Checking API compatibility.
2012/11/07 23:42:09 unknown kind in const "useDialTimeoutRace"
(*ast.BinaryExpr): in BinaryExpr, unhandled type mismatch; left="string",
right="ideal-string"
go tool api: exit status 1
------------------------------------------------------------------------------
Patch set 6 now causes the same error for adding 'import "time"' to
'src/pkg/net/ipsock.go'. Patching this file by hand makes the compiler runs fine
for patch set 6.
Issue 6815049: code review 6815049: net: close fds eagerly in DialTimeout
(Closed)
Created 11 years, 5 months ago by bradfitz
Modified 11 years, 5 months ago
Reviewers:
Base URL:
Comments: 9