Skip to content

Instantly share code, notes, and snippets.

View kazeburo's full-sized avatar

Masahiro Nagano kazeburo

View GitHub Profile
#!/usr/bin/perl
package AnyEvent::DNS::Cache::Simple;
use strict;
use warnings;
use base qw/AnyEvent::DNS/;
use Cache::Memory::Simple;
use Data::Dumper;
#!/usr/bin/perl
use strict;
use warnings;
package StarSoldier;
use base qw/Starlet::Server/;
use IO::Select;
use IO::Socket;
## see also https://metacpan.org/module/Sledge::Plugin::DebugLeakChecker
use Plack::Builder;
use Plack::Util;
use Devel::Leak::Object qw{ GLOBAL_bless };
use Text::SimpleTable;
my $leak_app = sub {
my $env = shift;
my $ref;$ref = bless \$ref, 'XXX';
use strict;
use Benchmark qw/ :all /;
use File::Temp qw/ tempfile /;
use Storable qw/ nstore retrieve /;
use HTTP::Request::Common;
use HTTP::Message::PSGI;
use Plack::Builder;
use Plack::Test;
diff -ur Alien-RRDtool-0.03.orig/Makefile.PL Alien-RRDtool-0.03/Makefile.PL
--- Alien-RRDtool-0.03.orig/Makefile.PL 2012-05-17 14:41:03.000000000 +0900
+++ Alien-RRDtool-0.03/Makefile.PL 2013-03-29 17:13:39.000000000 +0900
@@ -18,6 +18,7 @@
print "# => ", scalar mirror($rrdtool, "$name.tar.gz"), "\n";
print "# unpacking $name.tar.gz\n";
system("tar", "xzf", "$name.tar.gz");
+system("cd ${name}-1.4.7 && cat ../rrdtool.patch | patch -p1");
rmtree($name);
my $version = do {
diff --git a/Makefile.PL b/Makefile.PL
index c690aab..21e6d45 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -15,6 +15,8 @@ requires 'Try::Tiny';
requires 'parent';
requires 'Stream::Buffered', '0.02';
+requires 'Apache::LogFormat::Compiler', '0.05'; # Middleware::AccessLog
+
@kazeburo
kazeburo / gist:5150337
Last active December 14, 2015 21:19
Starletのheaderとbodyを一回のwriteで出力する閾値のテスト

applicationは

use Starlet;
print $Starlet::VERSION,"\n";
my $content="x"x4000;
sub{[200,[],[$content]]}

こんなの。4000byteのbodyを返す。 閾値を1024と4096で変更しながらテスト

#!/usr/bin/perl
use strict;
use warnings;
use Carp;
use Log::Minimal;
use IO::Socket::INET;
use POSIX qw(EINTR EAGAIN EWOULDBLOCK);
use Socket qw(IPPROTO_TCP TCP_NODELAY);
use HTTP::Parser::XS qw/HEADERS_NONE HEADERS_AS_ARRAYREF HEADERS_AS_HASHREF/;
diff --git a/lib/Starlet/Server.pm b/lib/Starlet/Server.pm
index 4b0bcdc..45664a3 100644
--- a/lib/Starlet/Server.pm
+++ b/lib/Starlet/Server.pm
@@ -89,8 +89,25 @@ sub accept_loop {
my($self, $app, $max_reqs_per_child) = @_;
my $proc_req_count = 0;
+ $self->{can_exit} = 1;
+ $self->{term_received} = 0;
diff --git a/lib/Plack/Request.pm b/lib/Plack/Request.pm
index 26e7a86..070558a 100644
--- a/lib/Plack/Request.pm
+++ b/lib/Plack/Request.pm
@@ -77,9 +77,18 @@ sub cookies {
sub query_parameters {
my $self = shift;
- my @combined = $self->uri->query_form;
- @combined = (@combined, map { $_, '' } $self->uri->query_keywords);