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

Issue 12170045: code review 12170045: syscall: add Dup3 on Linux (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 7 months ago by bradfitz
Modified:
11 years, 7 months ago
Reviewers:
r, iant
CC:
golang-dev, r
Visibility:
Public.

Description

syscall: add Dup3 on Linux With dup3, we can avoid an extra system call on some machines while holding syscall.ForkLock. Currently we have to syscall.Dup + syscall.CloseOnExec. On machines with Linux and a new enough kernel, this can just be dup3.

Patch Set 1 #

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

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

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+31 lines, -0 lines) Patch
M src/pkg/syscall/syscall_linux.go View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/syscall/zsyscall_linux_386.go View 1 1 chunk +10 lines, -0 lines 0 comments Download
M src/pkg/syscall/zsyscall_linux_amd64.go View 1 1 chunk +10 lines, -0 lines 0 comments Download
M src/pkg/syscall/zsyscall_linux_arm.go View 1 1 chunk +10 lines, -0 lines 0 comments Download

Messages

Total messages: 7
bradfitz
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
11 years, 7 months ago (2013-07-31 20:12:46 UTC) #1
r
Do we know the kernel is new enough? Would dup4 be 33% better?
11 years, 7 months ago (2013-08-01 00:59:46 UTC) #2
bradfitz
This doesn't use it yet. A future CL will conditionally use it, checking ENOSYS etc. ...
11 years, 7 months ago (2013-08-01 01:01:28 UTC) #3
r
LGTM
11 years, 7 months ago (2013-08-01 01:01:57 UTC) #4
bradfitz
*** Submitted as https://code.google.com/p/go/source/detail?r=c92197d20d7d *** syscall: add Dup3 on Linux With dup3, we can avoid ...
11 years, 7 months ago (2013-08-01 06:38:57 UTC) #5
iant
On Wed, Jul 31, 2013 at 1:12 PM, <bradfitz@golang.org> wrote: > > syscall: add Dup3 ...
11 years, 7 months ago (2013-08-02 23:15:25 UTC) #6
bradfitz
11 years, 7 months ago (2013-08-03 00:14:14 UTC) #7
On Fri, Aug 2, 2013 at 4:15 PM, Ian Lance Taylor <iant@golang.org> wrote:

> On Wed, Jul 31, 2013 at 1:12 PM,  <bradfitz@golang.org> wrote:
> >
> > syscall: add Dup3 on Linux
> >
> > With dup3, we can avoid an extra system call on some machines
> > while holding syscall.ForkLock. Currently we have to
> > syscall.Dup + syscall.CloseOnExec.
> >
> > On machines with Linux and a new enough kernel, this can just
> > be dup3.
>
> No objection to the CL, but I wonder how we can use this.  What we
> need in the net package is really dup+O_CLOEXEC.  Unfortunately dup3
> is dup2+O_CLOEXEC: it requires you to specify the new descriptor
> number.  I don't see how the net package can reliably determine a new
> descriptor number to use.
>

Yeah, I realized that later too. And then I laughed, thinking of Rob's dup4
remark.


> That is to say, what we should use in the net package is not dup3, but
> fcntl(fd.sysfd, F_DUPFD_CLOEXEC), which has been available since
> kernel version 2.6.24.
>

Nice. I'll try that.
Sign in to reply to this message.

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