pd := pollcache.alloc()
lock(&pd.lock)
if pd.wg != 0 && pd.wg != pdReady {
- throw("netpollOpen: blocked write on free descriptor")
+ throw("runtime: blocked write on free polldesc")
}
if pd.rg != 0 && pd.rg != pdReady {
- throw("netpollOpen: blocked read on free descriptor")
+ throw("runtime: blocked read on free polldesc")
}
pd.fd = fd
pd.closing = false
//go:linkname poll_runtime_pollClose internal/poll.runtime_pollClose
func poll_runtime_pollClose(pd *pollDesc) {
if !pd.closing {
- throw("netpollClose: close w/o unblock")
+ throw("runtime: close polldesc w/o unblock")
}
if pd.wg != 0 && pd.wg != pdReady {
- throw("netpollClose: blocked write on closing descriptor")
+ throw("runtime: blocked write on closing polldesc")
}
if pd.rg != 0 && pd.rg != pdReady {
- throw("netpollClose: blocked read on closing descriptor")
+ throw("runtime: blocked read on closing polldesc")
}
netpollclose(pd.fd)
pollcache.free(pd)
func poll_runtime_pollUnblock(pd *pollDesc) {
lock(&pd.lock)
if pd.closing {
- throw("netpollUnblock: already closing")
+ throw("runtime: unblock on closing polldesc")
}
pd.closing = true
pd.seq++
return true
}
if old != 0 {
- throw("netpollblock: double wait")
+ throw("runtime: double wait")
}
if atomic.Casuintptr(gpp, 0, pdWait) {
break
// be careful to not lose concurrent READY notification
old := atomic.Xchguintptr(gpp, 0)
if old > pdWait {
- throw("netpollblock: corrupted state")
+ throw("runtime: corrupted polldesc")
}
return old == pdReady
}
var rg *g
if read {
if pd.rd <= 0 || pd.rt.f == nil {
- throw("netpolldeadlineimpl: inconsistent read deadline")
+ throw("runtime: inconsistent read deadline")
}
pd.rd = -1
atomicstorep(unsafe.Pointer(&pd.rt.f), nil) // full memory barrier between store to rd and load of rg in netpollunblock
var wg *g
if write {
if pd.wd <= 0 || pd.wt.f == nil && !read {
- throw("netpolldeadlineimpl: inconsistent write deadline")
+ throw("runtime: inconsistent write deadline")
}
pd.wd = -1
atomicstorep(unsafe.Pointer(&pd.wt.f), nil) // full memory barrier between store to wd and load of wg in netpollunblock
closeonexec(epfd)
return
}
- println("netpollinit: failed to create epoll descriptor", -epfd)
- throw("netpollinit: failed to create descriptor")
+ println("runtime: epollcreate failed with", -epfd)
+ throw("runtime: netpollinit failed")
}
func netpolldescriptor() uintptr {
}
func netpollarm(pd *pollDesc, mode int) {
- throw("unused")
+ throw("runtime: unused")
}
// polls for ready network connections
if n < 0 {
if n != -_EINTR {
println("runtime: epollwait on fd", epfd, "failed with", -n)
- throw("epollwait failed")
+ throw("runtime: netpoll failed")
}
goto retry
}
func netpollinit() {
kq = kqueue()
if kq < 0 {
- println("netpollinit: kqueue failed with", -kq)
- throw("netpollinit: kqueue failed")
+ println("runtime: kqueue failed with", -kq)
+ throw("runtime: netpollinit failed")
}
closeonexec(kq)
}
}
func netpollarm(pd *pollDesc, mode int) {
- throw("unused")
+ throw("runtime: unused")
}
// Polls for ready network connections.
if n < 0 {
if n != -_EINTR {
println("runtime: kevent on fd", kq, "failed with", -n)
- throw("kevent failed")
+ throw("runtime: netpoll failed")
}
goto retry
}
return
}
- print("netpollinit: failed to create port (", errno(), ")\n")
- throw("netpollinit: failed to create port")
+ print("runtime: port_create failed (errno=", errno(), ")\n")
+ throw("runtime: netpollinit failed")
}
func netpolldescriptor() uintptr {
}
if events != 0 && port_associate(portfd, _PORT_SOURCE_FD, pd.fd, events, uintptr(unsafe.Pointer(pd))) != 0 {
- print("netpollupdate: failed to associate (", errno(), ")\n")
- throw("netpollupdate: failed to associate")
+ print("runtime: port_associate failed (errno=", errno(), ")\n")
+ throw("runtime: netpollupdate failed")
}
pd.user = events
}
case 'w':
netpollupdate(pd, _POLLOUT, 0)
default:
- throw("netpollarm: bad mode")
+ throw("runtime: bad mode")
}
unlock(&pd.lock)
}
var n uint32 = 1
if port_getn(portfd, &events[0], uint32(len(events)), &n, wait) < 0 {
if e := errno(); e != _EINTR {
- print("runtime: port_getn on fd ", portfd, " failed with ", e, "\n")
- throw("port_getn failed")
+ print("runtime: port_getn on fd ", portfd, " failed (errno=", e, ")\n")
+ throw("runtime: netpoll failed")
}
goto retry
}
func netpollinit() {
iocphandle = stdcall4(_CreateIoCompletionPort, _INVALID_HANDLE_VALUE, 0, 0, _DWORD_MAX)
if iocphandle == 0 {
- println("netpoll: failed to create iocp handle (errno=", getlasterror(), ")")
- throw("netpoll: failed to create iocp handle")
+ println("runtime: CreateIoCompletionPort failed (errno=", getlasterror(), ")")
+ throw("runtime: netpollinit failed")
}
}
}
func netpollarm(pd *pollDesc, mode int) {
- throw("unused")
+ throw("runtime: unused")
}
// Polls for completed network IO.
if !block && errno == _WAIT_TIMEOUT {
return nil
}
- println("netpoll: GetQueuedCompletionStatusEx failed (errno=", errno, ")")
- throw("netpoll: GetQueuedCompletionStatusEx failed")
+ println("runtime: GetQueuedCompletionStatusEx failed (errno=", errno, ")")
+ throw("runtime: netpoll failed")
}
mp.blocked = false
for i = 0; i < n; i++ {
return nil
}
if op == nil {
- println("netpoll: GetQueuedCompletionStatus failed (errno=", errno, ")")
- throw("netpoll: GetQueuedCompletionStatus failed")
+ println("runtime: GetQueuedCompletionStatus failed (errno=", errno, ")")
+ throw("runtime: netpoll failed")
}
// dequeued failed IO packet, so report that
}
func handlecompletion(gpp *guintptr, op *net_op, errno int32, qty uint32) {
if op == nil {
- throw("netpoll: GetQueuedCompletionStatus returned op == nil")
+ println("runtime: GetQueuedCompletionStatus returned op == nil")
+ throw("runtime: netpoll failed")
}
mode := op.mode
if mode != 'r' && mode != 'w' {
- println("netpoll: GetQueuedCompletionStatus returned invalid mode=", mode)
- throw("netpoll: GetQueuedCompletionStatus returned invalid mode")
+ println("runtime: GetQueuedCompletionStatus returned invalid mode=", mode)
+ throw("runtime: netpoll failed")
}
op.errno = errno
op.qty = qty