Commit 2ea859a7 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

runtime: refactor level-triggered IO support

Remove GOOS_solaris ifdef from netpoll code,
instead introduce runtime edge/level triggered IO flag.
Replace armread/armwrite with a single arm(mode) function,
that's how all other interfaces look like and these functions
will need to do roughly the same thing anyway.

LGTM=rsc
R=golang-codereviews, dave, rsc
CC=golang-codereviews
https://golang.org/cl/55500044
parent e1ee0482
...@@ -134,12 +134,9 @@ ret: ...@@ -134,12 +134,9 @@ ret:
func runtime_pollWait(pd *PollDesc, mode int) (err int) { func runtime_pollWait(pd *PollDesc, mode int) (err int) {
err = checkerr(pd, mode); err = checkerr(pd, mode);
if(err == 0) { if(err == 0) {
#ifdef GOOS_solaris // As for now only Solaris uses level-triggered IO.
if(mode == 'r') if(Solaris)
runtime·netpollarmread(pd->fd); runtime·netpollarm(pd->fd, mode);
else if(mode == 'w')
runtime·netpollarmwrite(pd->fd);
#endif
while(!netpollblock(pd, mode, false)) { while(!netpollblock(pd, mode, false)) {
err = checkerr(pd, mode); err = checkerr(pd, mode);
if(err != 0) if(err != 0)
...@@ -152,13 +149,8 @@ func runtime_pollWait(pd *PollDesc, mode int) (err int) { ...@@ -152,13 +149,8 @@ func runtime_pollWait(pd *PollDesc, mode int) (err int) {
} }
func runtime_pollWaitCanceled(pd *PollDesc, mode int) { func runtime_pollWaitCanceled(pd *PollDesc, mode int) {
#ifdef GOOS_solaris // This function is used only on windows after a failed attempt to cancel
if(mode == 'r') // a pending async IO operation. Wait for ioready, ignore closing or timeouts.
runtime·netpollarmread(pd->fd);
else if(mode == 'w')
runtime·netpollarmwrite(pd->fd);
#endif
// wait for ioready, ignore closing or timeouts.
while(!netpollblock(pd, mode, true)) while(!netpollblock(pd, mode, true))
; ;
} }
......
...@@ -52,6 +52,13 @@ runtime·netpollclose(uintptr fd) ...@@ -52,6 +52,13 @@ runtime·netpollclose(uintptr fd)
return -res; return -res;
} }
void
runtime·netpollarm(uintptr fd, int32 mode)
{
USED(fd, mode);
runtime·throw("unused");
}
// polls for ready network connections // polls for ready network connections
// returns list of goroutines that become runnable // returns list of goroutines that become runnable
G* G*
......
...@@ -59,6 +59,13 @@ runtime·netpollclose(uintptr fd) ...@@ -59,6 +59,13 @@ runtime·netpollclose(uintptr fd)
return 0; return 0;
} }
void
runtime·netpollarm(uintptr fd, int32 mode)
{
USED(fd, mode);
runtime·throw("unused");
}
// Polls for ready network connections. // Polls for ready network connections.
// Returns list of goroutines that become runnable. // Returns list of goroutines that become runnable.
G* G*
......
...@@ -72,6 +72,13 @@ runtime·netpollclose(uintptr fd) ...@@ -72,6 +72,13 @@ runtime·netpollclose(uintptr fd)
return 0; return 0;
} }
void
runtime·netpollarm(uintptr fd, int32 mode)
{
USED(fd, mode);
runtime·throw("unused");
}
// Polls for completed network IO. // Polls for completed network IO.
// Returns list of goroutines that become runnable. // Returns list of goroutines that become runnable.
G* G*
......
...@@ -893,8 +893,7 @@ int32 runtime·netpollopen(uintptr, PollDesc*); ...@@ -893,8 +893,7 @@ int32 runtime·netpollopen(uintptr, PollDesc*);
int32 runtime·netpollclose(uintptr); int32 runtime·netpollclose(uintptr);
void runtime·netpollready(G**, PollDesc*, int32); void runtime·netpollready(G**, PollDesc*, int32);
uintptr runtime·netpollfd(PollDesc*); uintptr runtime·netpollfd(PollDesc*);
void runtime·netpollarmread(uintptr fd); void runtime·netpollarm(uintptr, int32);
void runtime·netpollarmwrite(uintptr fd);
void runtime·crash(void); void runtime·crash(void);
void runtime·parsedebugvars(void); void runtime·parsedebugvars(void);
void _rt0_go(void); void _rt0_go(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment