[Bps-public-commit] r9956 - in Net-Server-Coro: .

alexmv at bestpractical.com alexmv at bestpractical.com
Fri Dec 14 18:01:29 EST 2007


Author: alexmv
Date: Fri Dec 14 18:01:28 2007
New Revision: 9956

Modified:
   Net-Server-Coro/   (props changed)
   Net-Server-Coro/lib/Net/Server/Coro.pm

Log:
 r25777 at zoq-fot-pik:  chmrr | 2007-12-14 18:01:19 -0500
  * Positioning on the EV loop matters?
  * Also, EV blocks *everything*, including signals,
    unless we make it wake up every once in a while.


Modified: Net-Server-Coro/lib/Net/Server/Coro.pm
==============================================================================
--- Net-Server-Coro/lib/Net/Server/Coro.pm	(original)
+++ Net-Server-Coro/lib/Net/Server/Coro.pm	Fri Dec 14 18:01:28 2007
@@ -74,16 +74,6 @@
     my $self = $SELF = shift;
     my $prop = $self->{server};
 
-    async {
-        # We want this to be higher priority so it gets timeslices
-        # when other things cede; this guarantees that we notice
-        # socket activity and deal.
-        $Coro::current->prio(3);
-        while () {
-            EV::loop();
-        }
-    };
-
     for my $socket ( @{ $prop->{sock} } ) {
         async {
             while (1) {
@@ -100,6 +90,23 @@
             }
         };
     }
+
+    async {
+        # We want this to be higher priority so it gets timeslices
+        # when other things cede; this guarantees that we notice
+        # socket activity and deal.
+        $Coro::current->prio(3);
+
+        # EV needs to service something before we notice signals.
+        # This interrupts the event loop every 10 seconds to force it
+        # to check if we got sent a SIGINT, for instance.  Otherwise
+        # it would hang until it got an I/O interrupt.
+        my $death_notice = EV::timer(10, 10, sub {});
+        while (1) {
+            EV::loop( );
+        }
+    };
+
     schedule;
 }
 



More information about the Bps-public-commit mailing list