This commit is contained in:
2019-02-06 00:49:12 +03:00
commit 8dbb1bb605
4796 changed files with 506072 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
1.43:
-- don't even try epoll if not on a known/tested arch
-- updated POD docs
1.42:
-- use the right epoll system call numbers on non-x86
machines
-- start of a good test suite
-- 64-bit struct support (test suite passes on ia64, ppc)
(and presumably ppc64, but yet untested)
1.41:
-- make the Poll mode behave like Epoll/Kqueue in that
fds returned w/ no corresponding Danga::Socket object
or OtherFds coderef just get ignored. make it robust
against apps with races, perhaps? patch from Justin Azoff
<JAzoff@uamail.albany.edu>
1.40:
-- Kqueue support from Matt Sergeant
1.39:
-- make BSD::Resource optional
1.38:
-- added support for profiling (epoll only at the moment while this
feature is further fleshed out); user application is required to
enable profiling and actually process the resultant data
-- if epoll_wait returns an event we can't handle, delete it.
this means the application fucked up and lost its state somehow.
or maybe Danga::Socket did? still debugging this in Perlbal.
1.25: (2004-10-22)
-- move the syscall.ph require into "package main" rather than stealing
all its definitions into our namespace. now other modules can
use syscall.ph and Danga::Socket at the same time (as long as they're
also polite and load it into main) (NOTE: if you know a better way
to do this, let us know...)
1.24: (2004-10-21)
-- ability to steal the underlying socket from the Danga::Socket
object. this is useful if a caller wants to hold onto the socket
but destroy the Danga::Socket object (previously the Danga::Socket
close would close the underlying socket)
1.22: (2004-10-21)
-- minimal POD docs
-- first public release

View File

@@ -0,0 +1,9 @@
Makefile.PL
CHANGES
MANIFEST
Socket.pm
META.yml Module meta-data (added by MakeMaker)
t/00-use.t
t/05-postloop.t
t/10-events.t

View File

@@ -0,0 +1,12 @@
^#
\bCVS\b
^MANIFEST\.
^Makefile$
~$
\.html$
\.old$
^blib/
_blib$
^MakeMaker-\d
^\.exists
\bdebian\b

View File

@@ -0,0 +1,15 @@
# 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.42
version_from: Socket.pm
installdirs: site
requires:
fields: 0
IO::Poll: 0
POSIX: 0
Socket: 0
Test::More: 0
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17

View File

@@ -0,0 +1,35 @@
#!/usr/bin/perl
#
# Perl Makefile for Danga-Socket
# $Id: Makefile.PL,v 1.6 2005/03/08 01:02:35 bradfitz Exp $
#
# Invoke with 'perl Makefile.PL'
#
# See ExtUtils::MakeMaker (3) for more information on how to influence
# the contents of the Makefile that is written
#
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Danga::Socket',
VERSION_FROM => 'Socket.pm', # finds $VERSION
AUTHOR => 'Brad Fitzpatrick <brad@danga.com>',
ABSTRACT => 'Async socket class',
PREREQ_PM => {
'Socket' => 0,
'IO::Poll' => 0,
fields => 0,
'POSIX' => 0,
'Test::More' => 0,
},
dist => {
CI => "cvs commit",
RCS_LABEL => 'cvs tag RELEASE_$(VERSION_SYM)',
SUFFIX => ".gz",
DIST_DEFAULT => 'all tardist',
COMPRESS => "gzip",
},
);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
libdanga-socket-perl (1.40-1) unstable; urgency=low
* New upstream version
-- Jay Bonci <jaybonci@debian.org> Tue, 5 Apr 2005 15:33:34 -0400
libdanga-socket-perl (1.38-1) unstable; urgency=low
* New upstream version
-- Jay Bonci <jaybonci@debian.org> Wed, 9 Feb 2005 02:32:07 -0500
libdanga-socket-perl (1.25-1) unstable; urgency=low
* Initial release
-- Jay Bonci <jaybonci@debian.org> Thu, 13 Jan 2005 23:13:18 -0500

View File

@@ -0,0 +1 @@
4

View File

@@ -0,0 +1,13 @@
Source: libdanga-socket-perl
Section: perl
Priority: optional
Maintainer: Jay Bonci <jaybonci@debian.org>
Build-Depends-Indep: debhelper (>= 4.1.40), perl (>= 5.8.4)
Standards-Version: 3.6.1.0
Package: libdanga-socket-perl
Architecture: all
Depends: ${perl:Depends}
Description: fast pure-perl asyncronous socket base class
Danga::Socket is an abstract base class which provides the basic framework for
event-driven asynchronous IO, designed to be fast.

View File

@@ -0,0 +1,26 @@
This package was debianized by Jay Bonci <jaybonci@debian.org> on
Thu Jan 13 23:18:32 EST 2005
It was downloaded from: http://www.danga.com/dist/Danga-Socket/
Upstream Authors:
Brad Fitzpatrick <brad@danga.com>
Michael Granger <ged@danga.com>
Mark Smith <marksmith@danga.com>
Copyright:
This program is free software; you can redistribute it and/or modify
it under the terms of either:
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"
See:
/usr/share/common-licenses/Artistic
/usr/share/common-licenses/GPL
For more information regarding these licensing options

View File

@@ -0,0 +1,53 @@
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# This is the debhelper compatibility version to use.
# export DH_COMPAT=4
#PACKAGE=`pwd | sed -e "s/.*\/\\(.*\\)-.*/\\1/"`
PACKAGE=`cat debian/control | perl -ne 'print if s/Package: (.*)/$$1/'`
build:
dh_testdir
# Add here commands to compile the package.
perl Makefile.PL verbose INSTALLDIRS=vendor
clean:
dh_testdir
dh_testroot
-$(MAKE) clean
rm -f Makefile.old
dh_clean
install:
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
$(MAKE) PREFIX=$(CURDIR)/debian/$(PACKAGE)/usr OPTIMIZE="-O2 -g -Wall" test install
-find $(CURDIR)/debian -type d | xargs rmdir -p --ignore-fail-on-non-empty
binary-arch:;
binary-indep: build install
dh_testdir
dh_testroot
dh_installdocs
dh_installman
dh_installchangelogs CHANGES
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_perl
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

View File

@@ -0,0 +1,3 @@
version=2
http://www.danga.com/dist/Danga-Socket/Danga-Socket-([0-9].*)\.tar.gz \
debian uupdate

View File

@@ -0,0 +1,8 @@
#!/usr/bin/perl -w
use strict;
use Test::More tests => 1;
my $mod = "Danga::Socket";
use_ok($mod);

View File

@@ -0,0 +1,24 @@
#!/usr/bin/perl -w
use strict;
use Test::More 'no_plan';
use Danga::Socket;
my ($t1, $t2, $iters);
$t1 = time();
$iters = 0;
Danga::Socket->SetLoopTimeout(250);
Danga::Socket->SetPostLoopCallback(sub {
$iters++;
return $iters < 4 ? 1 : 0;
});
Danga::Socket->EventLoop;
$t2 = time();
ok($iters == 4, "four iters");
ok($t2 == $t1 + 1, "took a second");

View File

@@ -0,0 +1,147 @@
#!/usr/bin/perl -w
use strict;
use Test::More tests => 24;
use Danga::Socket;
use IO::Socket::INET;
use POSIX;
use vars qw($done);
Danga::Socket::init_poller();
SKIP: {
my ($sysname, $nodename, $release, $version, $machine) = POSIX::uname();
skip "not on linux 2.6", 1 if $^O ne "linux" || $version =~ /^2\.[01234]/;
ok(Danga::Socket->HaveEpoll(), "using epoll");
}
for my $mode ("auto", "poll") {
$done = 0;
my $iters = 0;
is(Danga::Socket->WatchedSockets, 0, "no watched sockets");
Danga::Socket->SetLoopTimeout(150);
Danga::Socket->SetPostLoopCallback(sub {
return 0 if $done;
$iters++;
ok(Server->new, "created server") if $iters == 1;
if ($iters == 3) {
ok(ClientOut->new, "created client outgoing");
is(Danga::Socket->WatchedSockets, 2, "two watched sockets");
}
return 1;
});
if ($mode eq "poll") {
require IO::Poll;
Danga::Socket->PollEventLoop;
} else {
Danga::Socket->EventLoop;
}
ok($done, "$mode mode is done");
# check descriptor map status
my $map = Danga::Socket->DescriptorMap;
ok(ref $map eq "HASH", "map is hash");
is(scalar keys %$map, 3, "watching 3 connections");
Danga::Socket->Reset;
is(scalar keys %$map, 0, "watching 0 connections");
}
ok(1, "finish");
package Server;
use base 'Danga::Socket';
sub new {
my $class = shift;
my $ssock = IO::Socket::INET->new(Listen => 5,
LocalAddr => 'localhost',
LocalPort => 60000,
Proto => 'tcp',
ReuseAddr => 1,
Blocking => 0,
);
die "couldn't create socket" unless $ssock;
IO::Handle::blocking($ssock, 0);
my $self = $class->SUPER::new($ssock);
$self->watch_read(1);
return $self;
}
sub event_read {
my $self = shift;
while (my ($psock, $peeraddr) = $self->{sock}->accept) {
IO::Handle::blocking($psock, 0);
Test::More::ok($psock, "Server got incoming conn");
ClientIn->new($psock);
}
}
package ClientIn;
use base 'Danga::Socket';
use fields (
'lines', #[]
);
sub new {
my ($class, $sock) = @_;
my $self = fields::new($class);
$self->SUPER::new($sock); # init base fields
bless $self, ref $class || $class;
$self->watch_read(1);
$self->{lines} = [];
return $self;
}
sub event_read {
my $self = shift;
my $bref = $self->read(5000);
Test::More::ok($$bref eq "Hello!\n", "ClientIn got hello");
$self->watch_read(0);
$main::done = 1;
}
package ClientOut;
use base 'Danga::Socket';
use fields (
'connected', # 0 or 1
);
use Socket qw(PF_INET IPPROTO_TCP SOCK_STREAM);
sub new {
my $class = shift;
my $sock;
socket $sock, PF_INET, SOCK_STREAM, IPPROTO_TCP;
die "can't create outgoing sock" unless $sock && defined fileno($sock);
IO::Handle::blocking($sock, 0);
connect $sock, Socket::sockaddr_in(60000, Socket::inet_aton('127.0.0.1'));
my $self = fields::new($class);
$self->SUPER::new($sock);
bless $self, ref $class || $class;
$self->{'connected'} = 0;
$self->watch_write(1);
return $self;
}
sub event_write {
my $self = shift;
if (! $self->{'connected'}) {
Test::More::ok(1, "ClientOut connected");
$self->{'connected'} = 1;
}
$self->write("Hello!\n");
$self->watch_write(0);
}