1
0
mirror of https://github.com/golang/go synced 2024-10-04 22:21:22 -06:00
Commit Graph

110 Commits

Author SHA1 Message Date
Dmitriy Vyukov
ed8c5501c7 net: use SetFileCompletionNotificationModes on windows if available
This allows to skip GetQueuedCompletionStatus if an IO operation completes synchronously.
benchmark                    old ns/op    new ns/op    delta
BenchmarkTCP4Persistent          27669        25863   -6.53%
BenchmarkTCP4Persistent-2        18173        15908  -12.46%
BenchmarkTCP4Persistent-4        10390         9766   -6.01%

R=golang-dev, mikioh.mikioh, alex.brainman
CC=golang-dev
https://golang.org/cl/12409044
2013-08-08 17:36:43 +04:00
Dmitriy Vyukov
fc80764792 runtime/race: tell race detector what memory Read/Write syscalls touch
Fixes #5567.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/10085043
2013-06-10 22:40:35 +04:00
Alex Brainman
26498684cb os: use windows ReadConsole to read from console
Fixes #4760.

R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7312053
2013-02-26 14:18:48 +11:00
Alex Brainman
810e439859 net: use windows ConnectEx to dial (when possible)
Update #2631.
Update #3097.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7061060
2013-01-11 12:42:09 +11:00
Nick Craig-Wood
473441fc30 os: Improve the accuracy of os.Chtimes
I've been writing some code which involves syncing files (like
rsync) and it became apparent that under Linux I could read
modification times (os.Lstat) with nanosecond precision but
only write them with microsecond precision.  This difference
in precision is rather annoying when trying to discover
whether files need syncing or not!

I've patched syscall and os to increases the accuracy of of
os.Chtimes for Linux and Windows.  This involved exposing the
utimensat system call under Linux and a bit of extra code
under Windows.  I decided not to expose the "at" bit of the
system call as it is impossible to replicate under Windows, so
the patch adds syscall.Utimens() to all architectures along
with a ImplementsUtimens flag.

If the utimensat syscall isn't available (utimensat was added
to Linux in 2.6.22, Released, 8 July 2007) then it silently
falls back to the microsecond accuracy version it uses now.
The improved accuracy for Windows should be good for all
versions of Windows.

Unfortunately Darwin doesn't seem to have a utimensat system
call that I could find so I couldn't implement it there.  The
BSDs do, but since they share their syscall implementation
with Darwin I couldn't figure out how to define a syscall for
*BSD and not Darwin.  I've left this as a TODO in the code.

In the process I implemented the missing methods for Timespec
under Windows which I needed which just happened to round out
the Timespec API for all platforms!

------------------------------------------------------------

Test code: http://play.golang.org/p/1xnGuYOi4b

Linux Before (1000 ns precision)

$ ./utimetest.linux.before z
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 BST
Reading mtime 1344937903123457000: 2012-08-14 10:51:43.123457 +0100 BST

Linux After (1 ns precision)

$ ./utimetest.linux.after z
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 BST
Reading mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 BST

Windows Before (1000 ns precision)

X:\>utimetest.windows.before.exe c:\Test.txt
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 GMTDT
Reading mtime 1344937903123456000: 2012-08-14 10:51:43.123456 +0100 GMTDT

Windows After (100 ns precision)

X:\>utimetest.windows.after.exe c:\Test.txt
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 GMTDT
Reading mtime 1344937903123456700: 2012-08-14 10:51:43.1234567 +0100 GMTDT

R=golang-dev, alex.brainman, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6905057
2012-12-13 13:02:39 -08:00
Alex Brainman
eb2e6e59ee net: implement IPv6 support for windows
Thank you zhoumichaely for original CL 5175042.

Fixes #1740.
Fixes #2315.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev, zhoumichaely
https://golang.org/cl/6822045
2012-11-07 16:58:20 +11:00
Alex Brainman
fa3e4fc429 net: fix connection resets when closed on windows
It is common to close network connection while another goroutine is
blocked reading on another goroutine. This sequence corresponds to
windows calls to WSARecv to start io, followed by GetQueuedCompletionStatus
that blocks until io completes, and, finally, closesocket called from
another thread. We were expecting that closesocket would unblock
GetQueuedCompletionStatus, and it does, but not always
(http://code.google.com/p/go/issues/detail?id=4170#c5). Also that sequence
results in connection is being reset.

This CL inserts CancelIo between GetQueuedCompletionStatus and closesocket,
and waits for both WSARecv and GetQueuedCompletionStatus to complete before
proceeding to closesocket.  This seems to fix both connection resets and
issue 4170. It also makes windows code behave similar to unix version.

Unfortunately, CancelIo needs to be called on the same thread as WSARecv.
So we have to employ strategy we use for connections with deadlines to
every connection now. It means, there are 2 unavoidable thread switches
for every io. Some newer versions of windows have new CancelIoEx api that
doesn't have these drawbacks, and this CL uses this capability when available.
As time goes by, we should have less of CancelIo and more of CancelIoEx
systems. Computers with CancelIoEx are also not affected by issue 4195 anymore.

Fixes #3710
Fixes #3746
Fixes #4170
Partial fix for issue 4195

R=golang-dev, mikioh.mikioh, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6604072
2012-10-31 10:24:37 +11:00
Dmitriy Vyukov
cffbfaeb18 race: syscall changes
This is a part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044
The purpose of this patch is to provide coarse-grained synchronization
between all Read() and Write() calls.

R=rsc, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/6610064
2012-10-09 20:51:58 +04:00
Alex Brainman
0e6f927108 syscall: do not use int to test network syscall results (on windows)
Fixes #4147.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6569050
2012-09-25 17:06:39 +10:00
Alex Brainman
6e4d24999f syscall: attempt to find error message in "local" language before resorting to error number on windows
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6499121
2012-09-18 13:02:37 +10:00
Alex Brainman
18601f88fd os: detect and handle console in File.Write on windows
Fixes #3376.

R=golang-dev, bsiegert, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6488044
2012-09-12 12:04:45 +10:00
Shenghou Ma
f78ead3ca4 syscall: extract an ExampleLoadLibrary from comment
while we are at it, fix some out-of-date comments.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6498054
2012-08-29 21:44:46 +08:00
Alexey Borzenkov
a108369c83 syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.

R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 17:24:32 -04:00
Russ Cox
7762a9dc1f syscall: unexport GetCurrentProcessId on Windows
This slipped in with the implementation of Getpid in CL 5909043.
I'd exclude that CL entirely but it is tangled up in the Win32finddata changes.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6297065
2012-06-08 14:28:29 -04:00
Russ Cox
7ad37673e1 syscall: revert API changes in Windows Win32finddata fix.
Preserve old API by using correct struct in system call
and then copying the results, as we did for SetsockoptLinger.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6307065
2012-06-08 13:54:48 -04:00
Alex Brainman
8801402940 syscall: correct Win32finddata definition
Fixes #3685.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6261053
2012-06-03 19:27:17 +10:00
Alex Brainman
042848da65 syscall: simplify text returned by Errno.Error() when FormatMessage fails
Fixes #3623.

R=golang-dev, bsiegert, rsc
CC=golang-dev
https://golang.org/cl/6218072
2012-05-27 18:57:16 +10:00
Alex Brainman
50e5951374 syscall: implement SetsockoptLinger for windows
R=rsc
CC=golang-dev
https://golang.org/cl/6225048
2012-05-23 13:05:05 +10:00
Shenghou Ma
ae382129f1 syscall: support Getpid() on Windows
Fixes #3379.

R=golang-dev, alex.brainman, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5909043
2012-04-10 22:34:31 +08:00
Alex Brainman
7a39654174 path/filepath: use windows GetShortPathName api to force GetLongPathName to do its work
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5928043
2012-03-27 15:53:08 +11:00
Alex Brainman
0029b0d207 path/filepath: retrieve real file name in windows EvalSymlinks
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5756049
2012-03-08 10:00:25 +11:00
Mikkel Krautz
a324a5ac20 crypto/x509: new home for root fetchers; build chains using Windows API
This moves the various CA root fetchers from crypto/tls into crypto/x509.

The move was brought about by issue 2997. Windows doesn't ship with all
its root certificates, but will instead download them as-needed when using
CryptoAPI for certificate verification.

This CL changes crypto/x509 to verify a certificate using the system root
CAs when VerifyOptions.RootCAs == nil. On Windows, this verification is
now implemented using Windows's CryptoAPI. All other root fetchers are
unchanged, and still use Go's own verification code.

The CL also fixes the hostname matching logic in crypto/tls/tls.go, in
order to be able to test whether hostname mismatches are honored by the
Windows verification code.

The move to crypto/x509 also allows other packages to use the OS-provided
root certificates, instead of hiding them inside the crypto/tls package.

Fixes #2997.

R=agl, golang-dev, alex.brainman, rsc, mikkel
CC=golang-dev
https://golang.org/cl/5700087
2012-03-07 13:12:35 -05:00
Alex Brainman
c3fbc9a5e8 os: implement UserTime/SystemTime on windows
Fixes #3145.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5721044
2012-03-02 14:47:40 +11:00
Shenghou Ma
b17a233633 syscall: force Windows to always use US English error messages
Fixes #1834.

R=rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/5673068
2012-02-20 09:51:25 +11:00
Alex Brainman
07a2989d17 runtime, syscall, os/signal: fix windows build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5656048
2012-02-14 13:51:38 +11:00
Mikio Hara
804f1882c5 net, syscall: add IPv4 multicast helpers for windows
Also re-enable simple IPv4 multicast testing on windows.

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/5605048
2012-02-01 14:14:04 +09:00
Brad Fitzpatrick
7d418aeed2 syscall: add Unix method to TimeSpec, TimeVal
Fixes #2534

R=golang-dev, dave, alex.brainman
CC=golang-dev
https://golang.org/cl/5554057
2012-01-18 19:05:44 -08:00
Mikio Hara
92c8df46c6 src: make use of runtime.GOOS, GOARCH instead of syscall.OS, ARCH
R=rsc, r
CC=golang-dev
https://golang.org/cl/5545048
2012-01-14 06:40:55 +09:00
Mikio Hara
b06514bb34 syscall: fix windows build
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5533063
2012-01-10 18:27:09 -08:00
Mikio Hara
cbdbdc4f61 net: add IP-level socket option helpers for Unix variants
Also reorganize socket options stuff but there are no API behavioral
changes.

R=rsc, fullung
CC=golang-dev
https://golang.org/cl/5494067
2012-01-11 09:53:32 +09:00
Benny Siegert
5d045fb0f1 syscall: Remove obsolete Errstr call from commented-out example.
syscall_windows.go contains a small demo, which calls the obsolete
syscall.Errstr function.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/5475044
2011-12-09 10:42:34 +11:00
Alex Brainman
ef65feda2a syscall: return error, not uintptr, when function returns error
R=rsc
CC=golang-dev
https://golang.org/cl/5450119
2011-12-08 12:07:21 +11:00
Mikio Hara
cf4acf80b4 net, syscall: remove BindToDevice API from UDPConn, IPConn
For now a pair of socket options SOL_SOCKET and SO_BINDTODEVICE
is supported on Linux only. I'd like to demote BindToDevice API
to syscall level because it's Linux dependent one.

In the near future, probably we may have a bit more portable
API that using IPROTO_IP/IPV6 level socket options to specify,
identify an inbound, outbound IP interface on incoming, outgoing
UDP and raw IP packets.

R=cw, golang-dev
CC=golang-dev
https://golang.org/cl/5447071
2011-12-02 23:18:16 +09:00
Alex Brainman
d5f37122d2 crypto/tls: cleanup certificate load on windows
- correct syscall.CertEnumCertificatesInStore so it returns error
- remove "reflect" dependency

R=hectorchu, agl, rsc
CC=golang-dev, krautz
https://golang.org/cl/5441052
2011-12-01 12:38:00 -05:00
Alex Brainman
ac17fd4cd2 mime: implement TypeByExtension for windows
Fixes #2071.

R=golang-dev, hcwfrichter, pascal, rsc
CC=golang-dev
https://golang.org/cl/5369056
2011-11-18 10:07:36 +11:00
Alex Brainman
0d37998a06 syscall: make windows build again after d3963c0fca78 change
R=rsc, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5373097
2011-11-15 12:48:22 -05:00
Russ Cox
0acd879c26 syscall: take over env implementation
The environment is needed by package time, which
we want not to depend on os (so that os can use
time.Time), so push down into syscall.

Delete syscall.Sleep, now unnecessary.

The package os environment API is preserved;
it is only the implementation that is moving to syscall.

Delete os.Envs, which was undocumented,
uninitialized on Windows and Plan 9, and
not maintained by Setenv and Clearenv.
Code can call os.Environ instead.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5370091
2011-11-14 14:06:50 -05:00
Russ Cox
c017a8299f syscall: use error
- syscall (not os) now defines the Errno type.
- the low-level assembly functions Syscall, Syscall6, and so on
  return Errno, not uintptr
- syscall wrappers all return error, not uintptr.

R=golang-dev, mikioh.mikioh, r, alex.brainman
CC=golang-dev
https://golang.org/cl/5372080
2011-11-13 22:44:52 -05:00
Rob Pike
45e3bcb343 renaming_3: gofix -r go1pkgrename src/pkg/[m-z]*
R=rsc
CC=golang-dev
https://golang.org/cl/5345045
2011-11-08 15:41:54 -08:00
Russ Cox
db33959797 cgo, goyacc, go/build, html, http, path, path/filepath, testing/quick, test: use rune
Nothing terribly interesting here.

R=golang-dev, bradfitz, gri, r
CC=golang-dev
https://golang.org/cl/5300043
2011-10-25 22:20:02 -07:00
Hector Chu
7ecf6c997e exp/winfsnotify: filesystem watcher for Windows
R=rsc, alex.brainman, bradfitz
CC=bsiegert, go.peter.90, golang-dev
https://golang.org/cl/4188047
2011-10-18 21:09:58 +01:00
Alex Brainman
78479163cb syscall: dll function load and calling changes
New DLL and Proc types to manage and call dll functions. These were
used to simplify syscall tests in runtime package. They were also
used to implement LazyDLL and LazyProc.

LazyProc, like Proc, now have Call function, that just a wrapper for
SyscallN. It is not as efficient as Syscall, but easier to use.

NewLazyDLL now supports non-ascii filenames.

LazyDLL and LazyProc now have Load and Find methods. These can be used
during runtime to discover if some dll functions are not present.

All dll functions now return errors that fit os.Error interface. They
also contain Windows error number.

Some of these changes are suggested by jp.

R=golang-dev, jp, rsc
CC=golang-dev
https://golang.org/cl/5272042
2011-10-15 17:29:25 +11:00
Mikkel Krautz
3153395ed0 crypto/tls: fetch root CA from Windows store
R=rsc
CC=golang-dev
https://golang.org/cl/5281044
2011-10-13 22:58:19 -04:00
Alex Brainman
059c68bf0c net: implement ip protocol name to number resolver for windows
Fixes #2215.
Fixes #2216.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/5248055
2011-10-12 10:29:22 +11:00
Alex Brainman
7249fa773a syscall: mark stdin, stdout and stderr as non-inheritable by child process
Fixes #2250.

R=golang-dev, hectorchu
CC=golang-dev, vincent.vanackere
https://golang.org/cl/5086050
2011-09-23 18:16:13 +10:00
Paul Lalonde
bb8bbb2908 Windows: net, syscall: implement SetsockoptIPMReq(), move to winsock v2.2 for multicast support.
I don't know the protocol regarding the zsyscall files which appear to
be hand-generated, so I've re-done them and added them to the change.

R=rsc, alex.brainman, nigeltao
CC=golang-dev
https://golang.org/cl/4975060
2011-09-08 16:32:40 +10:00
Alex Brainman
37f390aa20 os: use GetFileAttributesEx to implement Stat on windows
Fixes #2129.

R=rsc
CC=golang-dev
https://golang.org/cl/4934049
2011-09-06 09:59:08 +10:00
Jaroslavas Počepko
95429d82f1 exp/wingui: made compatible with windows/amd64
R=golang-dev, alex.brainman
CC=golang-dev, vcc.163
https://golang.org/cl/4974041
2011-08-31 15:39:50 +10:00
Dmitriy Vyukov
381f6a2eeb syscall: make LazyDLL/LazyProc.Mutex unexported
They are seemingly not intended to be a part
of the public interface.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4873052
2011-08-16 18:33:48 +10:00
Alex Brainman
9d7e39340d syscall: delay load of dll functions until they are called
Before this change, syscall package would load
all dlls used anywhere in the go tree on startup.
For example, this program:

package main

import "fmt"

func main() {
       fmt.Printf("Hello world\n")
}

would load these dlls

kernel32.dll
advapi32.dll
shell32.dll
wsock32.dll
ws2_32.dll
dnsapi.dll
iphlpapi.dll

Most of these dlls are network related and are not used
in this program. Now the same program loads only

kernel32.dll
shell32.dll

This decreases start times somewhat.

This also relaxes the rules of which dlls can be included
in the standard library. We could now include system calls
that are not available on all versions of Windows, because
we could decide if we should call them during runtime.

R=rsc, vcc.163
CC=golang-dev
https://golang.org/cl/4815046
2011-07-31 20:07:04 +10:00