Subject: | Data::Transform support |
So, I uploaded a first version of Data::Transform to CPAN today, and I
thought I'd add a ticket with the patches to POE I would like to see for
it. (NOTE: these aren't final, ready-to-apply patches, but more a
starting point for discussion)
There isn't very much to them. One is a patch for POE::Wheel::ReadWrite
to send special packets right back into the driver without a round-trip
to the user (mostly needed for the ssl protocol in the upcoming
Data::Transform::SSL). Patches like this one are possibly needed for
some other Wheels, but I haven't yet looked into that.
The other two are patches to PoCo::*::TCP to send an EOF packet through
the filter chain (which may or may not end up generating a network
packet), so you can cleanly end the connection for protocols that send a
'goodbye' message.
Subject: | data-transform.patch |
diff -ur ../poe/lib/POE/Component/Client/TCP.pm lib/POE/Component/Client/TCP.pm
--- ../poe/lib/POE/Component/Client/TCP.pm 2008-07-15 23:47:51.000000000 +0200
+++ lib/POE/Component/Client/TCP.pm 2008-08-07 20:22:50.000000000 +0200
@@ -274,6 +274,7 @@
if ($heap->{connected}) {
$heap->{connected} = 0;
if (defined $heap->{server}) {
+ $heap->{server}->put(Data::Transform::Meta::EOF->new());
if (
$heap->{got_an_error} or
not $heap->{server}->get_driver_out_octets()
diff -ur ../poe/lib/POE/Component/Server/TCP.pm lib/POE/Component/Server/TCP.pm
--- ../poe/lib/POE/Component/Server/TCP.pm 2008-07-15 23:47:51.000000000 +0200
+++ lib/POE/Component/Server/TCP.pm 2008-08-07 20:22:35.000000000 +0200
@@ -261,6 +261,7 @@
my $heap = $_[HEAP];
$heap->{shutdown} = 1;
if (defined $heap->{client}) {
+ $heap->{client}->put(Data::Transform::Meta::EOF->new());
if (
$heap->{got_an_error} or
not $heap->{client}->get_driver_out_octets()
Only in ../poe/lib/POE/: Component.pm
Only in ../poe/lib/POE/: Driver
Only in ../poe/lib/POE/: Driver.pm
Only in ../poe/lib/POE/Filter: Block.pm
Only in ../poe/lib/POE/Filter: Grep.pm
Only in ../poe/lib/POE/Filter: HTTPD.pm
Only in ../poe/lib/POE/Filter: Line.pm
Only in ../poe/lib/POE/Filter: Map.pm
Only in ../poe/lib/POE/Filter: RecordBlock.pm
Only in ../poe/lib/POE/Filter: Reference.pm
Only in ../poe/lib/POE/Filter: Stackable.pm
Only in ../poe/lib/POE/Filter: Stream.pm
Only in ../poe/lib/POE/: Filter.pm
Only in ../poe/lib/POE/: Kernel.pm
Only in ../poe/lib/POE/: Loader.pm
Only in ../poe/lib/POE/: Loop
Only in ../poe/lib/POE/: Loop.pm
Only in ../poe/lib/POE/: NFA.pm
Only in ../poe/lib/POE/: Pipe
Only in ../poe/lib/POE/: Pipe.pm
Only in ../poe/lib/POE/: Queue
Only in ../poe/lib/POE/: Queue.pm
Only in ../poe/lib/POE/: Resource
Only in ../poe/lib/POE/: Resource.pm
Only in ../poe/lib/POE/: Resources.pm
Only in ../poe/lib/POE/: Session.pm
Only in ../poe/lib/POE/Wheel: Curses.pm
Only in ../poe/lib/POE/Wheel: FollowTail.pm
Only in ../poe/lib/POE/Wheel: ListenAccept.pm
Only in ../poe/lib/POE/Wheel: ReadLine.pm
diff -ur ../poe/lib/POE/Wheel/ReadWrite.pm lib/POE/Wheel/ReadWrite.pm
--- ../poe/lib/POE/Wheel/ReadWrite.pm 2008-06-27 11:40:25.000000000 +0200
+++ lib/POE/Wheel/ReadWrite.pm 2008-08-22 21:36:37.000000000 +0200
@@ -8,6 +8,7 @@
$VERSION = do {my($r)=(q$Revision$=~/(\d+)/);sprintf"1.%04d",$r};
use Carp qw( croak carp );
+use Scalar::Util qw(blessed);
use POE qw(Wheel Driver::SysRW Filter::Line);
# Offsets into $self.
@@ -256,6 +257,7 @@
my $driver = $self->[DRIVER_BOTH];
my $input_filter = \$self->[FILTER_INPUT];
my $event_input = \$self->[EVENT_INPUT];
+ my $handle_output = $self->[HANDLE_OUTPUT];
my $event_error = \$self->[EVENT_ERROR];
my $unique_id = $self->[UNIQUE_ID];
@@ -281,6 +283,13 @@
my $next_rec = $$input_filter->get_one();
last unless @$next_rec;
foreach my $cooked_input (@$next_rec) {
+ if (blessed ($cooked_input)) {
+ if ($cooked_input->isa('Data::Transform::Meta::SENDBACK')) {
+ $driver->put([$cooked_input->data]);
+ $k->select_resume_write($handle_output);
+ next;
+ }
+ }
$k->call($me, $$event_input, $cooked_input, $unique_id);
}
}
@@ -473,6 +482,12 @@
my $next_rec = $self->[FILTER_INPUT]->get_one();
last unless @$next_rec;
foreach my $cooked_input (@$next_rec) {
+ if (blessed ($cooked_input) and
+ $cooked_input->isa('Data::Transform::Meta::SENDBACK')) {
+ $self->[DRIVER_BOTH]->put([$cooked_input->{data}]);
+ $poe_kernel->select_resume_write($self->[HANDLE_OUTPUT]);
+ next;
+ }
$poe_kernel->call(
$poe_kernel->get_active_session(),
$self->[EVENT_INPUT],
Only in ../poe/lib/POE/Wheel: Run.pm
Only in ../poe/lib/POE/Wheel: SocketFactory.pm
Only in ../poe/lib/POE/: Wheel.pm