Title: POE::Driver::SysRW w/ Win32

Rocco,

I had to modify POE::Driver::SysRW to make it play better with Win32. Basically I had to modify it to handle EWOULDBLOCK where it handles EAGAIN...

--- c:\poe\poe\driver\SysRW.pm  Mon Nov 25 16:29:39 2002
+++ SysRW.pm    Thu Dec 05 13:23:16 2002
@@ -21,6 +21,10 @@
 sub BLOCK_SIZE          () { 3 }
 sub TOTAL_OCTETS_LEFT   () { 4 }
 
+BEGIN {
+    eval '*EWOULDBLOCK = sub { 10035 };'  if $^O eq 'MSWin32';
+}
+
 #------------------------------------------------------------------------------
 
 sub new {
@@ -106,7 +110,7 @@
   }
 
   # Nonfatal sysread() error.  Return an empty list.
-  return [ ] if $! == EAGAIN;
+  return [ ] if $! == EAGAIN or $! == EWOULDBLOCK;
 
   # fatal sysread error
   undef;
@@ -128,7 +132,7 @@
                               );
 
     unless ($wrote_count) {
-      $! = 0 if ($! == EAGAIN);
+      $! = 0 if ($! == EAGAIN or $! == EWOULDBLOCK);
       last;
     }
 
--
Garrett Goebel
IS Development Specialist

ScriptPro                   Direct: 913.403.5261
5828 Reeds Road               Main: 913.384.1008
Mission, KS 66202              Fax: 913.384.2180
www.scriptpro.com          [EMAIL PROTECTED]



> -----Original Message-----
> From: Rocco Caputo [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 28, 2002 7:10 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Pseudo Lexical State Parameters [x-adr]
>
>
> On Tue, Nov 12, 2002 at 09:40:35AM -0800, Erick Calder wrote:
> > > I like the simplicity of this syntax.
> >
> > me too.  I still prefer $kernel->yield() as it is simple,
> but certainly
> > kernel()->yield would be better than
> $message->kernel->yield()? i.e. where
> > "better" == "shorter" - me lazy and hate to read/type > I have to :)
> >
> > > Rather than patching Session.pm, I recommend subclassing it in the
> > > same vein as http://poe.perl.org/?POE_RFCs/Named_state_parameters
> >
> > why not patch Session.pm?  a switch in the create() to
> enable it seems this
> > functionality would make more sense.  in fact:
> >
> >     options => { parameters => $my_choice }
> >     where $my_choice could be "message" | "function" | "normal"
> >
> > .... that way I don't have to select which package I want. 
> I much prefer to:
> >
> >     use POE::Session;
> >
> > than:
> >
> >     use POE::Session::somethingorother;
> >
> > ....it's just simpler to think about.  anyway, just my tuppence.
>
> I like the options syntax, but I think combining all possible calling
> conventions into Session will turn it into a monolith.  One compromise
> would be to add the syntax while still using subclasses:
>
>   options => { subclass => $my_choice }
>   where $my_choice could be "MessageBased" | "Function" | default=none
>
> Internally, the constructor can load the subclass module as necessary
> and bless the new session into "POE::Session::$my_choice" rather than
> POE::Session.
>
> Combining all calling conventions into one class also introduces at
> least one more runtime condition in some of POE's hottest code.
> Dispatching events through a Session subclass would avoid the extra
> cycles.
>
> -- Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/
>

 

--- c:\poe\poe\driver\SysRW.pm  Mon Nov 25 16:29:39 2002
+++ SysRW.pm    Thu Dec 05 13:23:16 2002
@@ -21,6 +21,10 @@
 sub BLOCK_SIZE          () { 3 }
 sub TOTAL_OCTETS_LEFT   () { 4 }
 
+BEGIN {
+    eval '*EWOULDBLOCK = sub { 10035 };'  if $^O eq 'MSWin32';
+}
+
 #------------------------------------------------------------------------------
 
 sub new {
@@ -106,7 +110,7 @@
   }
 
   # Nonfatal sysread() error.  Return an empty list.
-  return [ ] if $! == EAGAIN;
+  return [ ] if $! == EAGAIN or $! == EWOULDBLOCK;
 
   # fatal sysread error
   undef;
@@ -128,7 +132,7 @@
                               );
 
     unless ($wrote_count) {
-      $! = 0 if ($! == EAGAIN);
+      $! = 0 if ($! == EAGAIN or $! == EWOULDBLOCK);
       last;
     }
 


Reply via email to