Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged in master

  • Loading branch information...
commit 1cb4e0b239f87143ab8b11981eba9f8097a1b9c3 2 parents e1889c6 + ef0378f
@marcusramberg marcusramberg authored
View
8 Changes
@@ -1,6 +1,12 @@
This file documents the revision history for Perl extension Mojolicious.
-2.52 2012-00-00 00:00:00
+
+2.52 2012-02-20 00:00:00
+ - Removed experimental status from config method in Mojo.
+ - Renamed to_psgi method in Mojo::Server::PSGI to to_psgi_app.
+ - Improved documentation.
+ - Fixed bug that prevented Mojo::IOLoop from dying when started
+ twice.
- Fixed a cookie jar path parsing bug.
2.51 2012-02-19 00:00:00
View
3  lib/Mojo.pm
@@ -156,8 +156,7 @@ object.
$app = $app->config({foo => 'bar'});
$app = $app->config(foo => 'bar');
-Application configuration. Note that this method is EXPERIMENTAL and might
-change without warning!
+Application configuration.
$app->config->{foo} = 'bar';
my $foo = $app->config->{foo};
View
5 lib/Mojo/IOLoop.pm
@@ -166,15 +166,14 @@ sub singleton { state $loop ||= shift->SUPER::new }
sub start {
my $self = shift;
$self = $self->singleton unless ref $self;
- croak 'Mojo::IOLoop already running' if $self->{running}++;
+ croak 'Mojo::IOLoop already running' if $self->is_running;
$self->iowatcher->start;
return $self;
}
sub stop {
my $self = shift;
- $self = $self->singleton unless ref $self;
- $self->iowatcher->stop if delete $self->{running};
+ (ref $self ? $self : $self->singleton)->iowatcher->stop;
}
sub stream {
View
3  lib/Mojo/IOWatcher.pm
@@ -225,7 +225,8 @@ amount of seconds.
$watcher->start;
-Start watching for I/O and timer events.
+Start watching for I/O and timer events, this will block until C<stop> is
+called.
=head2 C<stop>
View
3  lib/Mojo/IOWatcher/EV.pm
@@ -122,7 +122,8 @@ amount of seconds.
$watcher->start;
-Start watching for I/O and timer events.
+Start watching for I/O and timer events, this will block until C<stop> is
+called.
=head2 C<stop>
View
8 lib/Mojo/Server/PSGI.pm
@@ -49,7 +49,7 @@ sub run {
\@headers, Mojo::Server::PSGI::_IO->new(tx => $tx)];
}
-sub to_psgi {
+sub to_psgi_app {
(my $self = shift)->app;
return sub { $self->run(@_) }
}
@@ -110,7 +110,7 @@ Mojo::Server::PSGI - PSGI server
# Resume transaction
$tx->resume;
});
- my $app = $psgi->to_psgi;
+ my $app = $psgi->to_psgi_app;
=head1 DESCRIPTION
@@ -134,9 +134,9 @@ implements the following new ones.
Run L<PSGI>.
-=head2 C<to_psgi>
+=head2 C<to_psgi_app>
- my $app = $psgi->to_psgi;
+ my $app = $psgi->to_psgi_app;
Turn L<Mojo> application into L<PSGI> application. Note that this method is
EXPERIMENTAL and might change without warning!
View
4 lib/Mojolicious.pm
@@ -32,7 +32,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };
our $CODENAME = 'Leaf Fluttering In Wind';
-our $VERSION = '2.51';
+our $VERSION = '2.52';
# "These old doomsday devices are dangerously unstable.
# I'll rest easier not knowing where they are."
@@ -681,7 +681,7 @@ that have been used in the past.
0.999920, C<Snowman> (u2603)
-=head1 AUTHOR
+=head1 PROJECT FOUNDER
Sebastian Riedel, C<sri@cpan.org>
View
2  lib/Mojolicious/Command/psgi.pm
@@ -8,7 +8,7 @@ has usage => "usage: $0 psgi\n";
# "In the end it was not guns or bombs that defeated the aliens,
# but that humblest of all God's creatures... the Tyrannosaurus Rex."
-sub run { Mojo::Server::PSGI->new->to_psgi }
+sub run { Mojo::Server::PSGI->new->to_psgi_app }
1;
__END__
View
72 t/mojo/ioloop_tls.t
@@ -66,7 +66,7 @@ is $client, 'test321', 'right content';
$loop = Mojo::IOLoop->singleton;
$port = Mojo::IOLoop->generate_port;
$server = $client = '';
-my ($drop, $running, $timeout, $server_error, $server_close, $client_close);
+my ($drop, $running, $timeout, $server_err, $server_close, $client_close);
Mojo::IOLoop->drop(Mojo::IOLoop->recurring(0 => sub { $drop++ }));
$loop->server(
port => $port,
@@ -80,7 +80,7 @@ $loop->server(
$running = Mojo::IOLoop->is_running;
$stream->on(timeout => sub { $timeout++ });
$stream->on(close => sub { $server_close++ });
- $stream->on(error => sub { $server_error = pop });
+ $stream->on(error => sub { $server_err = pop });
$stream->on(read => sub { $server .= pop });
$stream->timeout('0.5');
}
@@ -105,60 +105,60 @@ is $timeout, 1, 'server emitted timeout event once';
is $server_close, 1, 'server emitted close event once';
is $client_close, 1, 'client emitted close event once';
ok $running, 'loop was running';
-ok !$drop, 'event dropped successfully';
-ok !$server_error, 'no error';
+ok !$drop, 'event dropped successfully';
+ok !$server_err, 'no error';
# Invalid client certificate
-my $client_error;
+my $client_err;
$loop->client(
port => $port,
tls => 1,
tls_cert => 't/mojo/certs/badclient.crt',
tls_key => 't/mojo/certs/badclient.key',
- sub { shift; $client_error = shift }
+ sub { shift; $client_err = shift }
);
$loop->timer(1 => sub { shift->stop });
$loop->start;
-ok $client_error, 'has error';
+ok $client_err, 'has error';
# Missing client certificate
-$server_error = $client_error = '';
-$loop->client(
- {port => $port, tls => 1} => sub { shift; $client_error = shift });
+$server_err = $client_err = '';
+$loop->client({port => $port, tls => 1} => sub { shift; $client_err = shift }
+);
$loop->timer(1 => sub { shift->stop });
$loop->start;
-ok !$server_error, 'no error';
-ok $client_error, 'has error';
+ok !$server_err, 'no error';
+ok $client_err, 'has error';
# Invalid certificate authority (server)
-$loop = Mojo::IOLoop->new;
-$port = Mojo::IOLoop->generate_port;
-$server_error = $client_error = '';
+$loop = Mojo::IOLoop->new;
+$port = Mojo::IOLoop->generate_port;
+$server_err = $client_err = '';
$loop->server(
port => $port,
tls => 1,
tls_ca => 'no cert',
tls_cert => 't/mojo/certs/server.crt',
tls_key => 't/mojo/certs/server.key',
- sub { $server_error = 'connected!' }
+ sub { $server_err = 'connected!' }
);
$loop->client(
port => $port,
tls => 1,
tls_cert => 't/mojo/certs/client.crt',
tls_key => 't/mojo/certs/client.key',
- sub { shift; $client_error = shift }
+ sub { shift; $client_err = shift }
);
$loop->timer(1 => sub { shift->stop });
$loop->start;
-ok !$server_error, 'no error';
-ok $client_error, 'has error';
+ok !$server_err, 'no error';
+ok $client_err, 'has error';
# Valid client and server certificates
$loop = Mojo::IOLoop->singleton;
$port = Mojo::IOLoop->generate_port;
$server = $client = '';
-($running, $timeout, $server_error, $server_close, $client_close) = undef;
+($running, $timeout, $server_err, $server_close, $client_close) = undef;
$loop->server(
port => $port,
tls => 1,
@@ -171,7 +171,7 @@ $loop->server(
$running = Mojo::IOLoop->is_running;
$stream->on(timeout => sub { $timeout++ });
$stream->on(close => sub { $server_close++ });
- $stream->on(error => sub { $server_error = pop });
+ $stream->on(error => sub { $server_err = pop });
$stream->on(read => sub { $server .= pop });
$stream->timeout('0.5');
}
@@ -197,48 +197,48 @@ is $timeout, 1, 'server emitted timeout event once';
is $server_close, 1, 'server emitted close event once';
is $client_close, 1, 'client emitted close event once';
ok $running, 'loop was running';
-ok !$server_error, 'no error';
+ok !$server_err, 'no error';
# Invalid server certificate
-$loop = Mojo::IOLoop->new;
-$port = Mojo::IOLoop->generate_port;
-$server_error = $client_error = '';
+$loop = Mojo::IOLoop->new;
+$port = Mojo::IOLoop->generate_port;
+$server_err = $client_err = '';
$loop->server(
port => $port,
tls => 1,
tls_cert => 't/mojo/certs/badclient.crt',
tls_key => 't/mojo/certs/badclient.key',
- sub { $server_error = 'connected!' }
+ sub { $server_err = 'connected!' }
);
$loop->client(
port => $port,
tls => 1,
tls_ca => 't/mojo/certs/ca.crt',
- sub { shift; $client_error = shift }
+ sub { shift; $client_err = shift }
);
$loop->timer(1 => sub { shift->stop });
$loop->start;
-ok !$server_error, 'no error';
-ok $client_error, 'has error';
+ok !$server_err, 'no error';
+ok $client_err, 'has error';
# Invalid certificate authority (client)
-$loop = Mojo::IOLoop->new;
-$port = Mojo::IOLoop->generate_port;
-$server_error = $client_error = '';
+$loop = Mojo::IOLoop->new;
+$port = Mojo::IOLoop->generate_port;
+$server_err = $client_err = '';
$loop->server(
port => $port,
tls => 1,
tls_cert => 't/mojo/certs/badclient.crt',
tls_key => 't/mojo/certs/badclient.key',
- sub { $server_error = 'connected!' }
+ sub { $server_err = 'connected!' }
);
$loop->client(
port => $port,
tls => 1,
tls_ca => 'no cert',
- sub { shift; $client_error = shift }
+ sub { shift; $client_err = shift }
);
$loop->timer(1 => sub { shift->stop });
$loop->start;
-ok !$server_error, 'no error';
-ok $client_error, 'has error';
+ok !$server_err, 'no error';
+ok $client_err, 'has error';
View
10 t/mojo/iowatcher.t
@@ -6,7 +6,7 @@ BEGIN {
$ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher';
}
-use Test::More tests => 64;
+use Test::More tests => 66;
# "I don't mind being called a liar when I'm lying, or about to lie,
# or just finished lying, but NOT WHEN I'M TELLING THE TRUTH."
@@ -190,7 +190,7 @@ $ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher';
is ref Mojo::IOLoop->singleton->iowatcher, 'Mojo::IOWatcher', 'right object';
ok !Mojo::IOLoop->is_running, 'loop is not running';
$port = Mojo::IOLoop->generate_port;
-my ($server_running, $client_running);
+my ($server_err, $server_running, $client_err, $client_running);
($server, $client) = '';
Mojo::IOLoop->server(
{port => $port} => sub {
@@ -198,6 +198,8 @@ Mojo::IOLoop->server(
$stream->write('test', sub { shift->write('321') });
$stream->on(read => sub { $server .= pop });
$server_running = Mojo::IOLoop->is_running;
+ eval { Mojo::IOLoop->start };
+ $server_err = $@;
}
);
Mojo::IOLoop->client(
@@ -206,11 +208,15 @@ Mojo::IOLoop->client(
$stream->write('tset', sub { shift->write('123') });
$stream->on(read => sub { $client .= pop });
$client_running = Mojo::IOLoop->is_running;
+ eval { Mojo::IOLoop->start };
+ $client_err = $@;
}
);
Mojo::IOLoop->timer(1 => sub { Mojo::IOLoop->singleton->iowatcher->stop });
Mojo::IOLoop->singleton->iowatcher->start;
ok !Mojo::IOLoop->is_running, 'loop is not running';
+like $server_err, qr/^Mojo::IOLoop already running/, 'right error';
+like $client_err, qr/^Mojo::IOLoop already running/, 'right error';
ok $server_running, 'loop is running';
ok $client_running, 'loop is running';
is $server, 'tset123', 'right content';
View
10 t/mojo/iowatcher_ev.t
@@ -8,7 +8,7 @@ use Test::More;
plan skip_all => 'set TEST_EV to enable this test (developer only!)'
unless $ENV{TEST_EV};
plan skip_all => 'EV 4.0 required for this test!' unless eval 'use EV 4.0; 1';
-plan tests => 64;
+plan tests => 66;
use IO::Socket::INET;
@@ -192,7 +192,7 @@ is ref Mojo::IOLoop->singleton->iowatcher, 'Mojo::IOWatcher::EV',
'right object';
ok !Mojo::IOLoop->is_running, 'loop is not running';
$port = Mojo::IOLoop->generate_port;
-my ($server_running, $client_running);
+my ($server_err, $server_running, $client_err, $client_running);
($server, $client) = '';
Mojo::IOLoop->server(
{port => $port} => sub {
@@ -200,6 +200,8 @@ Mojo::IOLoop->server(
$stream->write('test', sub { shift->write('321') });
$stream->on(read => sub { $server .= pop });
$server_running = Mojo::IOLoop->is_running;
+ eval { Mojo::IOLoop->start };
+ $server_err = $@;
}
);
Mojo::IOLoop->client(
@@ -208,11 +210,15 @@ Mojo::IOLoop->client(
$stream->write('tset', sub { shift->write('123') });
$stream->on(read => sub { $client .= pop });
$client_running = Mojo::IOLoop->is_running;
+ eval { Mojo::IOLoop->start };
+ $client_err = $@;
}
);
Mojo::IOLoop->timer(1 => sub { EV::break(EV::BREAK_ONE()) });
EV::run();
ok !Mojo::IOLoop->is_running, 'loop is not running';
+like $server_err, qr/^Mojo::IOLoop already running/, 'right error';
+like $client_err, qr/^Mojo::IOLoop already running/, 'right error';
ok $server_running, 'loop is running';
ok $client_running, 'loop is running';
is $server, 'tset123', 'right content';
View
2  t/mojo/psgi.t
@@ -34,7 +34,7 @@ post '/params' => sub {
};
# Binding
-my $app = Mojo::Server::PSGI->new->to_psgi;
+my $app = Mojo::Server::PSGI->new->to_psgi_app;
my $content = 'hello=world';
open my $body, '<', \$content;
my $env = {
Please sign in to comment.
Something went wrong with that request. Please try again.