r5136 - in
/packages/libdanga-socket-perl/branches/upstream/current: CHANGES
Danga-Socket.spec MANIFEST META.yml Socket.pm examples/
examples/subprocess/ examples/subprocess/example.pl
examples/subprocess/test.pl
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Wed Apr 18 09:00:37 UTC 2007
Author: eloy
Date: Wed Apr 18 09:00:37 2007
New Revision: 5136
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=5136
Log:
[svn-upgrade] Integrating new upstream version, libdanga-socket-perl (1.57)
Added:
packages/libdanga-socket-perl/branches/upstream/current/Danga-Socket.spec
packages/libdanga-socket-perl/branches/upstream/current/examples/
packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/
packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/example.pl
packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/test.pl
Modified:
packages/libdanga-socket-perl/branches/upstream/current/CHANGES
packages/libdanga-socket-perl/branches/upstream/current/MANIFEST
packages/libdanga-socket-perl/branches/upstream/current/META.yml
packages/libdanga-socket-perl/branches/upstream/current/Socket.pm
Modified: packages/libdanga-socket-perl/branches/upstream/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdanga-socket-perl/branches/upstream/current/CHANGES?rev=5136&op=diff
==============================================================================
--- packages/libdanga-socket-perl/branches/upstream/current/CHANGES (original)
+++ packages/libdanga-socket-perl/branches/upstream/current/CHANGES Wed Apr 18 09:00:37 2007
@@ -1,3 +1,8 @@
+1.57
+ -- Make tcp_cork be a no-op (rather than exploding) when operating on
+ a fd that isn't a network socket (like a local pipe, which doesn't do
+ TCP).
+
1.56
-- Reset method _still_ wasn't resetting enough. had to reset the
EventLoop method as well, so _InitPoller would get called and reset
Added: packages/libdanga-socket-perl/branches/upstream/current/Danga-Socket.spec
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdanga-socket-perl/branches/upstream/current/Danga-Socket.spec?rev=5136&op=file
==============================================================================
--- packages/libdanga-socket-perl/branches/upstream/current/Danga-Socket.spec (added)
+++ packages/libdanga-socket-perl/branches/upstream/current/Danga-Socket.spec Wed Apr 18 09:00:37 2007
@@ -1,0 +1,50 @@
+name: perl-Danga-Socket
+summary: Danga-Socket - Base class for asyncronous socket and timer manipulation.
+version: 1.56
+release: 1
+vendor: Brad Fitzpatrick <brad at danga.com>
+packager: Jonathan Steinert <hachi at cpan.org>
+license: Artistic
+group: Applications/CPAN
+buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n)
+buildarch: noarch
+source: Danga-Socket-%{version}.tar.gz
+
+
+%description
+Base class for asyncronous socket and timer manipulation.
+
+%prep
+rm -rf "%{buildroot}"
+%setup -n Danga-Socket-%{version}
+
+%build
+%{__perl} Makefile.PL PREFIX=%{buildroot}%{_prefix}
+make all
+make test
+
+%install
+make pure_install
+
+[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress
+
+
+# remove special files
+find %{buildroot} \( \
+ -name "perllocal.pod" \
+ -o -name ".packlist" \
+ -o -name "*.bs" \
+ \) -exec rm -f {} \;
+
+# no empty directories
+find %{buildroot}%{_prefix} \
+ -type d -depth -empty \
+ -exec rmdir {} \;
+
+%clean
+[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root)
+%{_prefix}/lib/*
+%{_prefix}/share/man/*
Modified: packages/libdanga-socket-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdanga-socket-perl/branches/upstream/current/MANIFEST?rev=5136&op=diff
==============================================================================
--- packages/libdanga-socket-perl/branches/upstream/current/MANIFEST (original)
+++ packages/libdanga-socket-perl/branches/upstream/current/MANIFEST Wed Apr 18 09:00:37 2007
@@ -1,10 +1,12 @@
+CHANGES
+Danga-Socket.spec
Makefile.PL
-CHANGES
MANIFEST
+META.yml Module meta-data (added by MakeMaker)
Socket.pm
-META.yml Module meta-data (added by MakeMaker)
t/00-use.t
t/05-postloop.t
t/10-events.t
t/12-closerace.t
-
+examples/subprocess/example.pl
+examples/subprocess/test.pl
Modified: packages/libdanga-socket-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdanga-socket-perl/branches/upstream/current/META.yml?rev=5136&op=diff
==============================================================================
--- packages/libdanga-socket-perl/branches/upstream/current/META.yml (original)
+++ packages/libdanga-socket-perl/branches/upstream/current/META.yml Wed Apr 18 09:00:37 2007
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Danga-Socket
-version: 1.56
+version: 1.57
version_from: Socket.pm
installdirs: site
requires:
Modified: packages/libdanga-socket-perl/branches/upstream/current/Socket.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdanga-socket-perl/branches/upstream/current/Socket.pm?rev=5136&op=diff
==============================================================================
--- packages/libdanga-socket-perl/branches/upstream/current/Socket.pm (original)
+++ packages/libdanga-socket-perl/branches/upstream/current/Socket.pm Wed Apr 18 09:00:37 2007
@@ -100,7 +100,7 @@
my $opt_bsd_resource = eval "use BSD::Resource; 1;";
use vars qw{$VERSION};
-$VERSION = "1.56";
+$VERSION = "1.57";
use warnings;
no warnings qw(deprecated);
@@ -823,8 +823,11 @@
# we're not closed already
warn "setsockopt: $!";
$self->close('tcp_cork_failed');
- } elsif ($! == ENOPROTOOPT) {
+ } elsif ($! == ENOPROTOOPT || $!{ENOTSOCK} || $!{EOPNOTSUPP}) {
# TCP implementation doesn't support corking, so just ignore it
+ # or we're trying to tcp-cork a non-socket (like a socketpair pipe
+ # which is acting like a socket, which Perlbal does for child
+ # processes acting like inetd-like web servers)
} else {
# some other error; we should never hit here, but if we do, die
die "setsockopt: $!";
Added: packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/example.pl
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/example.pl?rev=5136&op=file
==============================================================================
--- packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/example.pl (added)
+++ packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/example.pl Wed Apr 18 09:00:37 2007
@@ -1,0 +1,190 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use IO::Handle;
+use Socket;
+
+# CHANGE THIS!
+my $PROGRAM = "/home/hachi/test.pl";
+
+# Using IO::Handle::INET (or whatever that module is) actually blocks during
+# connect even if you set the 'blocking' option to 0.
+
+socket( my $server_sock, PF_INET, SOCK_STREAM, getprotobyname( 'tcp' ) )
+ or die( "socket failed: $!\n" );
+
+setsockopt( $server_sock, SOL_SOCKET, SO_REUSEADDR, pack( "l", 1 ) )
+ or die( "setsockopt failed: $!\n" );
+
+bind( $server_sock, sockaddr_in( 2345, INADDR_ANY ) )
+ or die( "bind failed: $!\n" );
+
+listen( $server_sock, SOMAXCONN )
+ or die( "listen failed: $!\n" );
+
+IO::Handle::blocking( $server_sock, 0 );
+
+Danga::Socket->AddOtherFds( fileno( $server_sock ), sub {
+ my $paddr = accept( my $client, $server_sock );
+ Client->new( $client );
+} );
+
+$SIG{CHLD} = 'IGNORE';
+
+Danga::Socket->EventLoop;
+
+warn "Clean Exit!\n";
+exit 0;
+
+package Client;
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+
+use base 'Danga::Socket';
+
+use fields qw(exec);
+
+sub new {
+ my Client $self = shift;
+ my $sock = shift;
+
+ $self = fields::new( $self ) unless ref $self;
+ $self->SUPER::new( $sock );
+
+ my $exec = Exec->new(
+ read => sub {
+ my $exec = shift;
+ my $input = $exec->read( 1024 );
+ if ($input) {
+ print "Exec for $exec->{pid} read: $$input\n";
+ $self->write( $input );
+ }
+ else {
+ $exec->watch_read( 0 );
+ }
+ },
+ program => $PROGRAM,
+ );
+
+ $exec->watch_read( 1 );
+
+ $self->{exec} = $exec;
+
+ return $self;
+}
+
+sub event_err {
+ my Client $self = shift;
+ $self->{exec}->kill;
+}
+
+sub event_hup {
+ my Client $self = shift;
+ $self->{exec}->kill( "INT" );
+}
+
+package Exec;
+
+use strict;
+use warnings;
+
+use Socket;
+use IO::Handle;
+
+use base 'Danga::Socket';
+
+use fields qw(pid read write err hup);
+
+sub new {
+ my Exec $self = shift;
+ my %opts = @_;
+
+ $self = fields::new( $self ) unless ref $self;
+
+ $self->{read} = delete( $opts{read} );
+ $self->{write} = delete( $opts{write} );
+ $self->{err} = delete( $opts{err} );
+ $self->{hup} = delete( $opts{hup} );
+
+ my $program = delete( $opts{program} )
+ or die( "Must supply a program argument" );
+ my $args = delete( $opts{args} ) || [];
+
+ die( "Unknown arguments" ) if keys( %opts );
+
+ socketpair( my $one, my $two, AF_UNIX, SOCK_STREAM, PF_UNSPEC )
+ or die( "Sockpair failed" );
+ IO::Handle::blocking( $one, 0 );
+ IO::Handle::blocking( $two, 0 );
+
+ # Try turning off autoflush on these, so stdio calls don't buffer
+ select((select( $one ), $|++)[0]);
+ select((select( $two ), $|++)[0]);
+
+ my $pid = fork();
+
+ die( "Fork failed: $!" ) unless defined( $pid );
+
+ if ($pid) {
+ # Parent process
+ $self->{pid} = $pid;
+ close $two;
+ $self->SUPER::new( $one );
+ return $self;
+ }
+ else {
+ # Child process
+ close $one;
+ close STDIN;
+ close STDOUT;
+
+ # DUP our $two handle into the 0 and 1 fd slots
+ open( STDIN, "<&" . fileno( $two ) )
+ or die( "Couldn't dup to STDIN in pid $$: $!" );
+ open( STDOUT, ">&" . fileno( $two ) )
+ or die( "Couldn't dup to STDOUT in pid $$: $!" );
+
+ exec( $program, @$args );
+
+ die( "Exec failed: $!" );
+ }
+}
+
+sub event_read {
+ my Exec $self = shift;
+ if (my $code = $self->{read}) {
+ $code->( $self );
+ }
+}
+
+sub event_write {
+ my Exec $self = shift;
+ if (my $code = $self->{write}) {
+ $code->( $self );
+ }
+}
+
+sub event_err {
+ my Exec $self = shift;
+ if (my $code = $self->{err}) {
+ $code->( $self );
+ }
+}
+
+sub event_hup {
+ my Exec $self = shift;
+ if (my $code = $self->{hup}) {
+ $code->( $self );
+ }
+}
+
+sub kill {
+ my Exec $self = shift;
+ my $signal = shift or return;
+ kill $signal, $self->{pid};
+}
Added: packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/test.pl
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/test.pl?rev=5136&op=file
==============================================================================
--- packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/test.pl (added)
+++ packages/libdanga-socket-perl/branches/upstream/current/examples/subprocess/test.pl Wed Apr 18 09:00:37 2007
@@ -1,0 +1,13 @@
+#!/usr/bin/perl
+
+# Autoflush somehow gets turned on for this handle, even when it's an
+# AF_UNIX socketpair
+$|++;
+
+use strict;
+use warnings;
+
+while (1) {
+ print( "[$$] Hello World\n" ) or die;
+ sleep 1;
+}
More information about the Pkg-perl-cvs-commits
mailing list