]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: refactor level-triggered IO support
authorDmitriy Vyukov <dvyukov@google.com>
Wed, 12 Feb 2014 18:24:29 +0000 (22:24 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Wed, 12 Feb 2014 18:24:29 +0000 (22:24 +0400)
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

src/pkg/runtime/netpoll.goc
src/pkg/runtime/netpoll_epoll.c
src/pkg/runtime/netpoll_kqueue.c
src/pkg/runtime/netpoll_windows.c
src/pkg/runtime/runtime.h

index 81471dca5bb55f07c372701095490772c4908edd..3f007073379395674196716e79b5f11014600f45 100644 (file)
@@ -134,12 +134,9 @@ ret:
 func runtime_pollWait(pd *PollDesc, mode int) (err int) {
        err = checkerr(pd, mode);
        if(err == 0) {
-#ifdef GOOS_solaris
-               if(mode == 'r')
-                       runtime·netpollarmread(pd->fd);
-               else if(mode == 'w')
-                       runtime·netpollarmwrite(pd->fd);
-#endif
+               // As for now only Solaris uses level-triggered IO.
+               if(Solaris)
+                       runtime·netpollarm(pd->fd, mode);
                while(!netpollblock(pd, mode, false)) {
                        err = checkerr(pd, mode);
                        if(err != 0)
@@ -152,13 +149,8 @@ func runtime_pollWait(pd *PollDesc, mode int) (err int) {
 }
 
 func runtime_pollWaitCanceled(pd *PollDesc, mode int) {
-#ifdef GOOS_solaris
-       if(mode == 'r')
-               runtime·netpollarmread(pd->fd);
-       else if(mode == 'w')
-               runtime·netpollarmwrite(pd->fd);
-#endif
-       // wait for ioready, ignore closing or timeouts.
+       // This function is used only on windows after a failed attempt to cancel
+       // a pending async IO operation. Wait for ioready, ignore closing or timeouts.
        while(!netpollblock(pd, mode, true))
                ;
 }
index 885ac5e4dfc7829e9dbebec9c20d00cdb5ececbd..318e0692991fbb49557cf94eb347ea660c90f1b0 100644 (file)
@@ -52,6 +52,13 @@ runtime·netpollclose(uintptr fd)
        return -res;
 }
 
+void
+runtime·netpollarm(uintptr fd, int32 mode)
+{
+       USED(fd, mode);
+       runtime·throw("unused");
+}
+
 // polls for ready network connections
 // returns list of goroutines that become runnable
 G*
index afc8d6859120e3d21172e615255a3cc353fc237e..7c5f12a1bd9411632c93190ed5ed1cbe690c25ae 100644 (file)
@@ -59,6 +59,13 @@ runtime·netpollclose(uintptr fd)
        return 0;
 }
 
+void
+runtime·netpollarm(uintptr fd, int32 mode)
+{
+       USED(fd, mode);
+       runtime·throw("unused");
+}
+
 // Polls for ready network connections.
 // Returns list of goroutines that become runnable.
 G*
index aeb065148cee7ec0e153b086d5ad5e03a7c34f80..a9f828c706d29ac917f81931c76417a1b18da26e 100644 (file)
@@ -72,6 +72,13 @@ runtime·netpollclose(uintptr fd)
        return 0;
 }
 
+void
+runtime·netpollarm(uintptr fd, int32 mode)
+{
+       USED(fd, mode);
+       runtime·throw("unused");
+}
+
 // Polls for completed network IO.
 // Returns list of goroutines that become runnable.
 G*
index ea42dbe59a08be35b08e6baa1ba33bfe92ee314d..57b5329e684950cecc422321c05ae3431826fb25 100644 (file)
@@ -893,8 +893,7 @@ int32       runtime·netpollopen(uintptr, PollDesc*);
 int32   runtime·netpollclose(uintptr);
 void   runtime·netpollready(G**, PollDesc*, int32);
 uintptr        runtime·netpollfd(PollDesc*);
-void   runtime·netpollarmread(uintptr fd);
-void   runtime·netpollarmwrite(uintptr fd);
+void   runtime·netpollarm(uintptr, int32);
 void   runtime·crash(void);
 void   runtime·parsedebugvars(void);
 void   _rt0_go(void);