Skip to content

Commit

Permalink
* munin-*cgi-graph: User contributed patch to avoid semafore overflow…
Browse files Browse the repository at this point in the history
…/deadlock in certain error conditions.
  • Loading branch information
Nicolai Langfeldt committed Dec 23, 2009
1 parent d53aa8b commit f73bca2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions master/_bin/munin-cgi-graph.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@

use RRDs;
use Munin::Master::Utils;
use Munin::Common::Defaults;
use strict;
use IO::Handle;
use Date::Manip;
use POSIX qw(strftime);
use IPC::SysV qw(IPC_CREAT);

my $GRAPHER = "@@LIBDIR@@/munin-graph";
my $conffile = "@@CONFDIR@@/munin.conf";
my $GRAPHER = "$Munin::Common::Defaults::MUNIN_LIBDIR/munin-graph";
my $conffile = "$Munin::Common::Defaults::MUNIN_CONFDIR/munin.conf";

my %TIMES = ( "day" => ["--noweek", "--nomonth", "--noyear", "--nosumweek", "--nosumyear"],
"week" => ["--noday", "--nomonth", "--noyear", "--nosumweek", "--nosumyear"],
Expand Down Expand Up @@ -140,7 +141,8 @@ sub sem_setup {
my $max_cgi_graph_jobs = &munin_get ($config, "max_cgi_graph_jobs" , 6, $dom);

# And initialize to max_cgi_graph_jobs
my $opstring = pack("s!s!s!",0, $max_cgi_graph_jobs,0);
# 0x1000 = SEM_UNDO
my $opstring = pack("s!s!s!",0, $max_cgi_graph_jobs,0x1000);
semop($semid,$opstring) || die "$!";
}
}
Expand Down Expand Up @@ -305,6 +307,7 @@ sub draw_graph {
my $IN;
sem_get();

# Note: This open is an implicit fork
if (! open ($IN, "-|")) {
%ENV=();
exec @params;
Expand Down
9 changes: 6 additions & 3 deletions master/_bin/munin-fastcgi-graph.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@

use RRDs;
use Munin::Master::Utils;
use Munin::Common::Defaults;
use strict;
use IO::Handle;
use Date::Manip;
use POSIX qw(strftime);
use IPC::SysV qw(IPC_CREAT);
use CGI::Fast;

my $GRAPHER = "@@LIBDIR@@/munin-graph";
my $conffile = "@@CONFDIR@@/munin.conf";
my $GRAPHER = "$Munin::Common::Defaults::MUNIN_LIBDIR/munin-graph";
my $conffile = "$Munin::Common::Defaults::MUNIN_CONFDIR/munin.conf";

my %TIMES = ( "day" => ["--noweek", "--nomonth", "--noyear", "--nosumweek", "--nosumyear"],
"week" => ["--noday", "--nomonth", "--noyear", "--nosumweek", "--nosumyear"],
Expand Down Expand Up @@ -142,7 +143,8 @@ sub sem_setup {
my $max_cgi_graph_jobs = &munin_get ($config, "max_cgi_graph_jobs" , 6, $dom);

# And initialize to max_cgi_graph_jobs
my $opstring = pack("s!s!s!",0, $max_cgi_graph_jobs,0);
# 0x1000 is SEM_UNDO
my $opstring = pack("s!s!s!",0, $max_cgi_graph_jobs,0x1000);
semop($semid,$opstring) || die "$!";
}
}
Expand Down Expand Up @@ -311,6 +313,7 @@ sub draw_graph {
my $IN;
sem_get();

# Note: This open is an implicit fork
if (! open ($IN, "-|")) {
%ENV=();
exec @params;
Expand Down

0 comments on commit f73bca2

Please sign in to comment.