* [PATCH 1/5] wwwstatic: getline: die on missing psgix.io
2019-12-31 10:30 7% [PATCH 0/5] some minor cleanups and doc updates Eric Wong
@ 2019-12-31 10:30 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2019-12-31 10:30 UTC (permalink / raw)
To: meta
"psgix." extensions aren't guaranteed, so make we should
try and support some theoretical generic PSGI servers
without "psgix.io" on errors by die-ing.
While we're at it, make the error handling path more obvious by
sharing more code between the EOF and errno ($!) cases.
---
lib/PublicInbox/WwwStatic.pm | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/lib/PublicInbox/WwwStatic.pm b/lib/PublicInbox/WwwStatic.pm
index 76e50c78..58db58b4 100644
--- a/lib/PublicInbox/WwwStatic.pm
+++ b/lib/PublicInbox/WwwStatic.pm
@@ -77,25 +77,23 @@ sub response {
# called by PSGI servers:
sub getline {
my ($self) = @_;
- my $len = $self->{len};
- return if $len == 0;
+ my $len = $self->{len} or return; # undef, tells server we're done
my $n = delete($self->{initial_rd}) // 8192;
$n = $len if $len < $n;
my $r = sysread($self->{in}, my $buf, $n);
- if (!defined $r) {
- $self->{env}->{'psgi.errors'}->print(
- "$self->{path} read error: $!\n");
- } elsif ($r > 0) { # success!
+ if (defined $r && $r > 0) { # success!
$self->{len} = $len - $r;
return $buf;
- } else {
- $self->{env}->{'psgi.errors'}->print(
- "$self->{path} EOF with $len bytes left\n");
}
+ my $m = defined $r ? "EOF with $len bytes left" : "read error: $!";
+ my $env = $self->{env};
+ $env->{'psgi.errors'}->print("$self->{path} $m\n");
# drop the client on error
- if (my $io = $self->{env}->{'psgix.io'}) {
- $io->close; # this is PublicInbox::DS::close
+ if (my $io = $env->{'psgix.io'}) {
+ $io->close; # this is likely PublicInbox::DS::close
+ } else { # for some PSGI servers w/o psgix.io
+ die "dropping client socket\n";
}
undef;
}
^ permalink raw reply related [relevance 7%]
* [PATCH 0/5] some minor cleanups and doc updates
@ 2019-12-31 10:30 7% Eric Wong
2019-12-31 10:30 7% ` [PATCH 1/5] wwwstatic: getline: die on missing psgix.io Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2019-12-31 10:30 UTC (permalink / raw)
To: meta
Actual features coming, later, but some cleanups and internal
doc updates I found along the way. I'm a tiny bit worried
about PATCH 3/5 breaking somebody's setup because of old
versions of examples/public-inbox.psgi, but considering how
little adoption this project had in 2016, maybe it's not a
big deal...
Eric Wong (5):
wwwstatic: getline: die on missing psgix.io
http: update comment about psgix.io usage
githttpbackend: remove ancient compatibility check
filter/base: export REJECT as a constant
cgit: type declaration for PublicInbox::Git
lib/PublicInbox/Cgit.pm | 3 ++-
lib/PublicInbox/Filter/Base.pm | 2 ++
lib/PublicInbox/GitHTTPBackend.pm | 3 ---
lib/PublicInbox/HTTP.pm | 2 +-
lib/PublicInbox/InboxWritable.pm | 3 +--
lib/PublicInbox/WatchMaildir.pm | 3 +--
lib/PublicInbox/WwwStatic.pm | 20 +++++++++-----------
script/public-inbox-purge | 4 +---
8 files changed, 17 insertions(+), 23 deletions(-)
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-12-31 10:30 7% [PATCH 0/5] some minor cleanups and doc updates Eric Wong
2019-12-31 10:30 7% ` [PATCH 1/5] wwwstatic: getline: die on missing psgix.io Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).