Skip to content

Commit

Permalink
do not recreate json decoder all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Sep 29, 2015
1 parent 24b1575 commit 1a1586f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 9 additions & 2 deletions lib/Monitoring/Livestatus.pm
Expand Up @@ -1141,7 +1141,12 @@ sub _read_socket_do {
$self->{'logger'}->debug("header: $header") if $self->{'verbose'};
my($status, $msg, $content_length) = &_parse_header($self, $header, $sock);
return($status, $msg, undef) if !defined $content_length;
my $json_decoder = JSON::XS->new->utf8->relaxed;
our $json_decoder;
if($json_decoder) {
$json_decoder->incr_reset;
} else {
$json_decoder = JSON::XS->new->utf8->relaxed;
}
if($content_length > 0) {
if($status == 200) {
my $remaining = $content_length;
Expand Down Expand Up @@ -1514,10 +1519,12 @@ see the Livestatus page: http://mathias-kettner.de/checkmk_livestatus.html
=head1 AUTHOR
Sven Nierlein, 2009-2014, <sven@nierlein.org>
Sven Nierlein, 2009-present, <sven@nierlein.org>
=head1 COPYRIGHT AND LICENSE
Copyright (C) by Sven Nierlein
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Expand Down
4 changes: 2 additions & 2 deletions lib/Monitoring/Livestatus/INET.pm
Expand Up @@ -107,11 +107,11 @@ sub _close {

=head1 AUTHOR
Sven Nierlein, 2009-2014, <sven@nierlein.org>
Sven Nierlein, 2009-present, <sven@nierlein.org>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2009 by Sven Nierlein
Copyright (C) by Sven Nierlein
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Expand Down
4 changes: 2 additions & 2 deletions lib/Monitoring/Livestatus/UNIX.pm
Expand Up @@ -110,11 +110,11 @@ sub _close {

=head1 AUTHOR
Sven Nierlein, 2009-2014, <sven@nierlein.org>
Sven Nierlein, 2009-present, <sven@nierlein.org>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2009 by Sven Nierlein
Copyright (C) by Sven Nierlein
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Expand Down

0 comments on commit 1a1586f

Please sign in to comment.