From cea9c0ce5b487fc156d7e6f60875d7e93083ac3c Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 16 Mar 2024 00:15:52 -0400 Subject: [PATCH] always read counter.numb (for secret threaded servers) --- counter.numb | 1 - myapp.pl | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) delete mode 100644 counter.numb diff --git a/counter.numb b/counter.numb deleted file mode 100644 index 573541a..0000000 --- a/counter.numb +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/myapp.pl b/myapp.pl index 9123211..fbce331 100755 --- a/myapp.pl +++ b/myapp.pl @@ -19,6 +19,7 @@ app->hook(before_server_start => sub ($server, $app) { }); get '/' => sub ($c) { + update_counter(); # hypnotoad or w/e may run on threads or something. awkward. make_image(to_number_length($counter++)); $c->res->headers->header('Content-Security-Policy' => 'img-src * artemis.venus.place'); $c->res->headers->header('Server' => 'nginx/1.22.1'); # lie :) @@ -28,6 +29,12 @@ get '/' => sub ($c) { close $fh; }; +sub update_counter () { + open my $fh, '<', $counter_file; + sysread $fh, $counter, 20; + close $fh; +} + sub to_number_length ($counter) { while (length $counter lt 6) { $counter = "0$counter";