summaryrefslogtreecommitdiff
path: root/src/pkg/net/fd_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/net/fd_windows.go')
-rw-r--r--src/pkg/net/fd_windows.go48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/pkg/net/fd_windows.go b/src/pkg/net/fd_windows.go
index 9ed7801d2..41d06120a 100644
--- a/src/pkg/net/fd_windows.go
+++ b/src/pkg/net/fd_windows.go
@@ -29,8 +29,8 @@ func init() {
}
}
-func closesocket(s int) (errno int) {
- return syscall.Closesocket(int32(s))
+func closesocket(s syscall.Handle) (errno int) {
+ return syscall.Closesocket(s)
}
// Interface for all io operations.
@@ -88,7 +88,7 @@ func (o *bufOp) Init(fd *netFD, buf []byte) {
// iocp and send them to the correspondent waiting client
// goroutine via channel supplied in the request.
type resultSrv struct {
- iocp int32
+ iocp syscall.Handle
}
func (s *resultSrv) Run() {
@@ -132,7 +132,7 @@ func (s *ioSrv) ProcessRemoteIO() {
case o := <-s.submchan:
o.Op().errnoc <- o.Submit()
case o := <-s.canchan:
- o.Op().errnoc <- syscall.CancelIo(uint32(o.Op().fd.sysfd))
+ o.Op().errnoc <- syscall.CancelIo(syscall.Handle(o.Op().fd.sysfd))
}
}
}
@@ -189,7 +189,7 @@ var onceStartServer sync.Once
func startServer() {
resultsrv = new(resultSrv)
var errno int
- resultsrv.iocp, errno = syscall.CreateIoCompletionPort(-1, 0, 0, 1)
+ resultsrv.iocp, errno = syscall.CreateIoCompletionPort(syscall.InvalidHandle, 0, 0, 1)
if errno != 0 {
panic("CreateIoCompletionPort failed " + syscall.Errstr(errno))
}
@@ -209,7 +209,7 @@ type netFD struct {
closing bool
// immutable until Close
- sysfd int
+ sysfd syscall.Handle
family int
proto int
net string
@@ -225,7 +225,7 @@ type netFD struct {
wio sync.Mutex
}
-func allocFD(fd, family, proto int, net string) (f *netFD) {
+func allocFD(fd syscall.Handle, family, proto int, net string) (f *netFD) {
f = &netFD{
sysfd: fd,
family: family,
@@ -236,13 +236,13 @@ func allocFD(fd, family, proto int, net string) (f *netFD) {
return f
}
-func newFD(fd, family, proto int, net string) (f *netFD, err os.Error) {
+func newFD(fd syscall.Handle, family, proto int, net string) (f *netFD, err os.Error) {
if initErr != nil {
return nil, initErr
}
onceStartServer.Do(startServer)
// Associate our socket with resultsrv.iocp.
- if _, e := syscall.CreateIoCompletionPort(int32(fd), resultsrv.iocp, 0, 0); e != 0 {
+ if _, e := syscall.CreateIoCompletionPort(syscall.Handle(fd), resultsrv.iocp, 0, 0); e != 0 {
return nil, os.Errno(e)
}
return allocFD(fd, family, proto, net), nil
@@ -280,7 +280,7 @@ func (fd *netFD) decref() {
// use the resultsrv for Close too. Sigh.
syscall.SetNonblock(fd.sysfd, false)
closesocket(fd.sysfd)
- fd.sysfd = -1
+ fd.sysfd = syscall.InvalidHandle
// no need for a finalizer anymore
runtime.SetFinalizer(fd, nil)
}
@@ -288,7 +288,7 @@ func (fd *netFD) decref() {
}
func (fd *netFD) Close() os.Error {
- if fd == nil || fd.sysfd == -1 {
+ if fd == nil || fd.sysfd == syscall.InvalidHandle {
return os.EINVAL
}
@@ -307,7 +307,7 @@ type readOp struct {
func (o *readOp) Submit() (errno int) {
var d, f uint32
- return syscall.WSARecv(uint32(o.fd.sysfd), &o.buf, 1, &d, &f, &o.o, nil)
+ return syscall.WSARecv(syscall.Handle(o.fd.sysfd), &o.buf, 1, &d, &f, &o.o, nil)
}
func (o *readOp) Name() string {
@@ -322,7 +322,7 @@ func (fd *netFD) Read(buf []byte) (n int, err os.Error) {
defer fd.rio.Unlock()
fd.incref()
defer fd.decref()
- if fd.sysfd == -1 {
+ if fd.sysfd == syscall.InvalidHandle {
return 0, os.EINVAL
}
var o readOp
@@ -344,7 +344,7 @@ type readFromOp struct {
func (o *readFromOp) Submit() (errno int) {
var d, f uint32
l := int32(unsafe.Sizeof(o.rsa))
- return syscall.WSARecvFrom(uint32(o.fd.sysfd), &o.buf, 1, &d, &f, &o.rsa, &l, &o.o, nil)
+ return syscall.WSARecvFrom(o.fd.sysfd, &o.buf, 1, &d, &f, &o.rsa, &l, &o.o, nil)
}
func (o *readFromOp) Name() string {
@@ -362,7 +362,7 @@ func (fd *netFD) ReadFrom(buf []byte) (n int, sa syscall.Sockaddr, err os.Error)
defer fd.rio.Unlock()
fd.incref()
defer fd.decref()
- if fd.sysfd == -1 {
+ if fd.sysfd == syscall.InvalidHandle {
return 0, nil, os.EINVAL
}
var o readFromOp
@@ -380,7 +380,7 @@ type writeOp struct {
func (o *writeOp) Submit() (errno int) {
var d uint32
- return syscall.WSASend(uint32(o.fd.sysfd), &o.buf, 1, &d, 0, &o.o, nil)
+ return syscall.WSASend(o.fd.sysfd, &o.buf, 1, &d, 0, &o.o, nil)
}
func (o *writeOp) Name() string {
@@ -395,7 +395,7 @@ func (fd *netFD) Write(buf []byte) (n int, err os.Error) {
defer fd.wio.Unlock()
fd.incref()
defer fd.decref()
- if fd.sysfd == -1 {
+ if fd.sysfd == syscall.InvalidHandle {
return 0, os.EINVAL
}
var o writeOp
@@ -412,7 +412,7 @@ type writeToOp struct {
func (o *writeToOp) Submit() (errno int) {
var d uint32
- return syscall.WSASendto(uint32(o.fd.sysfd), &o.buf, 1, &d, 0, o.sa, &o.o, nil)
+ return syscall.WSASendto(o.fd.sysfd, &o.buf, 1, &d, 0, o.sa, &o.o, nil)
}
func (o *writeToOp) Name() string {
@@ -430,7 +430,7 @@ func (fd *netFD) WriteTo(buf []byte, sa syscall.Sockaddr) (n int, err os.Error)
defer fd.wio.Unlock()
fd.incref()
defer fd.decref()
- if fd.sysfd == -1 {
+ if fd.sysfd == syscall.InvalidHandle {
return 0, os.EINVAL
}
var o writeToOp
@@ -443,14 +443,14 @@ func (fd *netFD) WriteTo(buf []byte, sa syscall.Sockaddr) (n int, err os.Error)
type acceptOp struct {
anOp
- newsock int
+ newsock syscall.Handle
attrs [2]syscall.RawSockaddrAny // space for local and remote address only
}
func (o *acceptOp) Submit() (errno int) {
var d uint32
l := uint32(unsafe.Sizeof(o.attrs[0]))
- return syscall.AcceptEx(uint32(o.fd.sysfd), uint32(o.newsock),
+ return syscall.AcceptEx(o.fd.sysfd, o.newsock,
(*byte)(unsafe.Pointer(&o.attrs[0])), 0, l, l, &d, &o.o)
}
@@ -459,7 +459,7 @@ func (o *acceptOp) Name() string {
}
func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err os.Error) {
- if fd == nil || fd.sysfd == -1 {
+ if fd == nil || fd.sysfd == syscall.InvalidHandle {
return nil, os.EINVAL
}
fd.incref()
@@ -478,7 +478,7 @@ func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err os.
// Associate our new socket with IOCP.
onceStartServer.Do(startServer)
- if _, e = syscall.CreateIoCompletionPort(int32(s), resultsrv.iocp, 0, 0); e != 0 {
+ if _, e = syscall.CreateIoCompletionPort(s, resultsrv.iocp, 0, 0); e != 0 {
return nil, &OpError{"CreateIoCompletionPort", fd.net, fd.laddr, os.Errno(e)}
}
@@ -493,7 +493,7 @@ func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err os.
}
// Inherit properties of the listening socket.
- e = syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_UPDATE_ACCEPT_CONTEXT, fd.sysfd)
+ e = syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_UPDATE_ACCEPT_CONTEXT, int(fd.sysfd))
if e != 0 {
closesocket(s)
return nil, err