From 1a1586fb84636b8f12e7dc77c586621f9917fc98 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Tue, 29 Sep 2015 10:27:51 +0200 Subject: [PATCH] do not recreate json decoder all the time --- lib/Monitoring/Livestatus.pm | 11 +++++++++-- lib/Monitoring/Livestatus/INET.pm | 4 ++-- lib/Monitoring/Livestatus/UNIX.pm | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/Monitoring/Livestatus.pm b/lib/Monitoring/Livestatus.pm index 1181338..70429f4 100644 --- a/lib/Monitoring/Livestatus.pm +++ b/lib/Monitoring/Livestatus.pm @@ -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; @@ -1514,10 +1519,12 @@ see the Livestatus page: http://mathias-kettner.de/checkmk_livestatus.html =head1 AUTHOR -Sven Nierlein, 2009-2014, +Sven Nierlein, 2009-present, =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. diff --git a/lib/Monitoring/Livestatus/INET.pm b/lib/Monitoring/Livestatus/INET.pm index 844b19d..90546c9 100644 --- a/lib/Monitoring/Livestatus/INET.pm +++ b/lib/Monitoring/Livestatus/INET.pm @@ -107,11 +107,11 @@ sub _close { =head1 AUTHOR -Sven Nierlein, 2009-2014, +Sven Nierlein, 2009-present, =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. diff --git a/lib/Monitoring/Livestatus/UNIX.pm b/lib/Monitoring/Livestatus/UNIX.pm index 0f02771..c0802d3 100644 --- a/lib/Monitoring/Livestatus/UNIX.pm +++ b/lib/Monitoring/Livestatus/UNIX.pm @@ -110,11 +110,11 @@ sub _close { =head1 AUTHOR -Sven Nierlein, 2009-2014, +Sven Nierlein, 2009-present, =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.