We replace the current Open with:
OpenFile(name, flag, perm) // same as old Open
Open(name) // same as old Open(name, O_RDONLY, 0)
Create(name) // same as old Open(name, O_RDWR|O_TRUNC|O_CREAT, 0666)
This CL includes a gofix module and full code updates: all.bash passes.
(There may be a few comments I missed.)
The interesting packages are:
gofix
os
Everything else is automatically generated except for hand tweaks to:
src/pkg/io/ioutil/ioutil.go
src/pkg/io/ioutil/tempfile.go
src/pkg/crypto/tls/generate_cert.go
src/cmd/goyacc/goyacc.go
src/cmd/goyacc/units.y
R=golang-dev, bradfitzwork, rsc, r2
CC=golang-dev
https://golang.org/cl/4357052
It was left in netFD.connect() by an oversight (as the name
implies, bind has no business being in connect). As a result
of this change and by only calling netFD.connect() when ra
isn't nil it becomes simpler with less code duplication.
Additionally, if netFD.connect() fails, set sysfd to -1 to
avoid finalizers (e.g. on windows) calling shutdown on a
closed and possibly reopened socket that just happened to
share the same descriptor.
R=golang-dev, rsc1, rsc
CC=golang-dev
https://golang.org/cl/4328043
Refactored bind/connect from sock.go into netFD.connect(), as
a consequence newFD() doesn't accept laddr/raddr anymore, and
expects an (optional) call to netFD.connect() followed by a
call to netFD.setAddr().
Windows code is updated, but still uses blocking connect,
since otherwise it needs support for ConnectEx syscall.
R=brainman, rsc
CC=golang-dev
https://golang.org/cl/4303060
Drop laddr argument from Dial.
Drop cname return from LookupHost.
Add LookupIP, LookupCNAME, ParseCIDR, IP.Equal.
Export SplitHostPort, JoinHostPort.
Add AAAA (IPv6) support to host lookups.
Preparations for implementing some of the
lookups using cgo.
ParseCIDR and IP.Equal are logically new in this CL
but accidentally snuck into an earlier CL about unused
labels that was in the same client.
In crypto/tls, drop laddr from Dial to match net.
R=golang-dev, dsymonds, adg, rh
CC=golang-dev
https://golang.org/cl/4244055
With gccgo some operating systems require using select rather
than epoll or kevent. Using select means that we have to wake
up the polling thread each time we add a new file descriptor.
This implements that in the generic code rather than adding
another wakeup channel, even though nothing in the current net
package uses the capability.
R=rsc, iant2
CC=golang-dev
https://golang.org/cl/4284069
In conjunction with the non-blocking system call CL, this
gives about an 8% performance improvement on a client/server
test running on my local machine.
R=rsc, iant2
CC=golang-dev
https://golang.org/cl/4272057
The loop always makes an extra system call. It only makes a
difference if more than 100 goroutines started waiting for
something to happen on a network file descriptor since the
last time the pipe was drained, which is unlikely since we
will be woken up the first time a goroutine starts waiting.
If we don't drain the pipe this time, we'll be woken up again
right away and can drain again.
R=rsc
CC=golang-dev
https://golang.org/cl/4275042
notes:
Darwin is very particular about joining a multicast group if the
listneing socket is not created in "udp4" mode, the other supported
OS's are more flexible.
A simple example sets up a socket to listen on the mdns/bonjour
group 224.0.0.251:5353
// ensure the sock is udp4, and the IP is a 4 byte IPv4
socket, err := net.ListenUDP("udp4", &net.UDPAddr {
IP: net.IPv4zero,
// currently darwin will not allow you to bind to
// a port if it is already bound to another process
Port: 5353,
})
if err != nil {
log.Exitf("listen %s", err)
}
defer socket.Close()
err = socket.JoinGroup(net.IPv4(224, 0, 0, 251))
if err != nil {
log.Exitf("join group %s", err)
}
R=adg, rsc
CC=golang-dev
https://golang.org/cl/4066044
The test code used to do this:
for _, tc := range tests {
ch <- &tc
}
Note that &tc is always the same value here. As the value is
received from the channel, the sender can loop around and
change the contents of tc. This means that the receiver's
value is unstable and can change while it is in use.
R=adg, r2, rsc
CC=chris, golang-dev
https://golang.org/cl/3978043
The recent linker changes broke NaCl support
a month ago, and there are no known users of it.
The NaCl code can always be recovered from the
repository history.
R=adg, r
CC=golang-dev
https://golang.org/cl/3671042