Navigation Menu

Skip to content

Commit

Permalink
better description of lock_file setting
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 14, 2012
1 parent 3eb7538 commit a2cda22
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo.pm
Expand Up @@ -5,6 +5,7 @@ use Carp 'croak';
use Mojo::Home;
use Mojo::Log;
use Mojo::Transaction::HTTP;
use Mojo::UserAgent;
use Scalar::Util 'weaken';

has home => sub { Mojo::Home->new };
Expand All @@ -13,7 +14,6 @@ has ua => sub {
my $self = shift;

# Fresh user agent
require Mojo::UserAgent;
my $ua = Mojo::UserAgent->new->app($self);
weaken $self;
$ua->on(error => sub { $self->log->error(pop) });
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/IOLoop/Server.pm
Expand Up @@ -211,7 +211,7 @@ sub _cert_file {
unless my $file = IO::File->new("> $cert");
print $file CERT;

$self->{cert} = $cert;
return $self->{cert} = $cert;
}

sub _key_file {
Expand All @@ -227,7 +227,7 @@ sub _key_file {
unless my $file = IO::File->new("> $key");
print $file KEY;

$self->{key} = $key;
return $self->{key} = $key;
}

# "Where on my badge does it say anything about protecting people?
Expand Down
16 changes: 7 additions & 9 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -14,9 +14,6 @@ use POSIX qw/setsid WNOHANG/;
use Scalar::Util 'weaken';
use Time::HiRes 'ualarm';

# Preload
require Mojo::UserAgent;

sub DESTROY {
my $self = shift;

Expand Down Expand Up @@ -287,8 +284,8 @@ sub _pid_file {
return if -e (my $file = $self->{config}->{pid_file});

# Create PID file
$self->{log}->info(qq/Creating PID file "$file"./);
croak qq/Can't create PID file "$file": $!/
$self->{log}->info(qq/Creating process id file "$file"./);
croak qq/Can't create process id file "$file": $!/
unless my $pid = IO::File->new($file, '>', 0644);
print $pid $$;
}
Expand Down Expand Up @@ -565,7 +562,8 @@ also L<Mojo::Server::Daemon/"listen"> for more examples.
lock_file => '/tmp/hypnotoad.lock'
Full path to accept mutex lock file, defaults to a random temporary file.
Full path of accept mutex lock file prefix, to which the process id will be
appended, defaults to a random temporary path.
=head2 C<lock_timeout>
Expand All @@ -578,9 +576,9 @@ accept mutex, defaults to C<0.5>.
pid_file => '/var/run/hypnotoad.pid'
Full path to PID file, defaults to C<hypnotoad.pid> in the same directory as
the application. Note that this value can only be changed after the server
has been stopped.
Full path to process id file, defaults to C<hypnotoad.pid> in the same
directory as the application. Note that this value can only be changed after
the server has been stopped.
=head2 C<proxy>
Expand Down
48 changes: 23 additions & 25 deletions lib/Mojo/Util.pm
@@ -1,11 +1,11 @@
package Mojo::Util;
use Mojo::Base 'Exporter';

require Digest::MD5;
require Digest::SHA;
require Encode;
require MIME::Base64;
require MIME::QuotedPrint;
use Digest::MD5 qw/md5 md5_hex/;
use Digest::SHA qw/sha1 sha1_hex/;
use Encode 'find_encoding';
use MIME::Base64 qw/decode_base64 encode_base64/;
use MIME::QuotedPrint qw/decode_qp encode_qp/;

# Punycode bootstring parameters
use constant {
Expand Down Expand Up @@ -288,16 +288,17 @@ $ENTITIES{apos} = 39;
my %ENCODE;

# "Bart, stop pestering Satan!"
our @EXPORT_OK = qw/b64_decode b64_encode camelize decamelize decode encode/;
push @EXPORT_OK, qw/get_line hmac_md5_sum hmac_sha1_sum html_escape/;
push @EXPORT_OK, qw/html_unescape md5_bytes md5_sum punycode_decode/;
push @EXPORT_OK, qw/punycode_encode qp_decode qp_encode quote/;
push @EXPORT_OK, qw/secure_compare sha1_bytes sha1_sum trim unquote/;
push @EXPORT_OK, qw/url_escape url_unescape xml_escape/;
our @EXPORT_OK = (
qw/b64_decode b64_encode camelize decamelize decode encode get_line/,
qw/hmac_md5_sum hmac_sha1_sum html_escape html_unescape md5_bytes md5_sum/,
qw/punycode_decode punycode_encode qp_decode qp_encode quote/,
qw/secure_compare sha1_bytes sha1_sum trim unquote url_escape/,
qw/url_unescape xml_escape/
);

sub b64_decode { MIME::Base64::decode_base64(shift) }
sub b64_decode { decode_base64(shift) }

sub b64_encode { MIME::Base64::encode_base64(shift, shift) }
sub b64_encode { encode_base64(shift, shift) }

sub camelize {
my $string = shift;
Expand Down Expand Up @@ -345,8 +346,7 @@ sub decode {
# Everything else
else {
$bytes =
($ENCODE{$encoding} ||= Encode::find_encoding($encoding))
->decode($bytes, 1);
($ENCODE{$encoding} ||= find_encoding($encoding))->decode($bytes, 1);
}

1;
Expand All @@ -365,8 +365,7 @@ sub encode {
}

# Everything else
return ($ENCODE{$encoding} ||= Encode::find_encoding($encoding))
->encode($chars);
return ($ENCODE{$encoding} ||= find_encoding($encoding))->encode($chars);
}

sub get_line {
Expand Down Expand Up @@ -423,8 +422,8 @@ sub html_unescape {
return $string;
}

sub md5_bytes { Digest::MD5::md5(@_) }
sub md5_sum { Digest::MD5::md5_hex(@_) }
sub md5_bytes { md5(@_) }
sub md5_sum { md5_hex(@_) }

sub punycode_decode {
my $input = shift;
Expand Down Expand Up @@ -545,9 +544,9 @@ sub punycode_encode {
return $output;
}

sub qp_decode { MIME::QuotedPrint::decode_qp(shift) }
sub qp_decode { decode_qp(shift) }

sub qp_encode { MIME::QuotedPrint::encode_qp(shift) }
sub qp_encode { encode_qp(shift) }

sub quote {
my $string = shift;
Expand All @@ -563,8 +562,8 @@ sub secure_compare {
return $r == 0 ? 1 : undef;
}

sub sha1_bytes { Digest::SHA::sha1(@_) }
sub sha1_sum { Digest::SHA::sha1_hex(@_) }
sub sha1_bytes { sha1(@_) }
sub sha1_sum { sha1_hex(@_) }

sub trim {
my $string = shift;
Expand Down Expand Up @@ -638,8 +637,7 @@ sub _hmac {
my ($sha, $string, $secret) = @_;

# Hash function
my $hash =
$sha ? sub { Digest::SHA::sha1(@_) } : sub { Digest::MD5::md5(@_) };
my $hash = $sha ? sub { sha1(@_) } : sub { md5(@_) };

# Secret
$secret ||= 'Very unsecure!';
Expand Down

0 comments on commit a2cda22

Please sign in to comment.