summaryrefslogtreecommitdiff
path: root/rh-bin/musicgrid.cgi
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-01-06 23:18:28 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-01-06 23:18:28 (GMT)
commit9a756a08d8e2f103fc010fcf4a11d5da94464c2d (patch)
tree7de11cd2edbcae53e9c529eacfac17e1ca4c0306 /rh-bin/musicgrid.cgi
parentb508322f56292b0d4d9fbf41389a1c0fee5befdf (diff)
fix bug which produces empty grid list when http connection is reused
Diffstat (limited to 'rh-bin/musicgrid.cgi')
-rwxr-xr-xrh-bin/musicgrid.cgi21
1 files changed, 7 insertions, 14 deletions
diff --git a/rh-bin/musicgrid.cgi b/rh-bin/musicgrid.cgi
index 5e2888d..9cd0837 100755
--- a/rh-bin/musicgrid.cgi
+++ b/rh-bin/musicgrid.cgi
@@ -30,25 +30,12 @@ use RHRD::rddb;
my $status = 'ERROR';
my $errorstring = 'unknown';
my $responsecode = 500;
-my @clocks = ();
my $q = CGI->new;
my $username = $q->param('LOGIN_NAME');
my $token = $q->param('PASSWORD');
my $cmd = $q->request_method();
-sub get_clocks
-{
- my ($ctx) = @_;
-
- @clocks = RHRD::rddb::get_musicpools_clocks($ctx);
- if(!defined $clocks[0] && defined $clocks[1]) {
- return 500, $clocks[1] . ": " . $clocks[2];
- }
-
- return 200, "OK";
-}
-
sub set_clock
{
my ($ctx) = @_;
@@ -77,6 +64,7 @@ sub set_clock
return 200, "OK";
}
+my @clocks = ();
if(!defined $username) {
$responsecode = 400;
$errorstring = "mandatory field LOGIN_NAME is missing";
@@ -90,7 +78,12 @@ if(!defined $username) {
my $authorized = RHRD::rddb::is_musicpools_user($ctx, $username);
if($authenticated == 1 && $authorized == 1) {
if($cmd eq "GET") {
- ($responsecode, $errorstring) = get_clocks($ctx);
+ @clocks = RHRD::rddb::get_musicpools_clocks($ctx);
+ if(!defined $clocks[0] && defined $clocks[1]) {
+ ($responsecode, $errorstring) = (500, $clocks[1] . ": " . $clocks[2]);
+ } else {
+ ($responsecode, $errorstring) = (200, "OK");
+ }
}
elsif($cmd eq "POST") {
($responsecode, $errorstring) = set_clock($ctx);