From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Stoiko Ivanov <s.ivanov@proxmox.com>
Subject: Re: [pve-devel] [PATCH http-server 3/3] add debug log for problems during accept
Date: Fri, 4 Dec 2020 07:37:17 +0100 [thread overview]
Message-ID: <f6e09680-c3d6-a453-6c55-7666d0c6ed26@proxmox.com> (raw)
In-Reply-To: <20201203184322.20253-4-s.ivanov@proxmox.com>
On 03.12.20 19:43, Stoiko Ivanov wrote:
> Co-Authored-by: Dominik Csapak <d.csapak@proxmox.com>
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
> PVE/APIServer/AnyEvent.pm | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm
> index 7038b07..d33f6b0 100644
> --- a/PVE/APIServer/AnyEvent.pm
> +++ b/PVE/APIServer/AnyEvent.pm
> @@ -1520,6 +1520,11 @@ sub check_host_access {
>
> my $cip = Net::IP->new($clientip);
>
> + if (!$cip) {
> + print "$$: check_host_access: clientip not parsable: $@\n" if $self->{debug};
I'd avoid using variable names 1:1 in log messages for such things, use "client IP"
(for not hard coding sub name see below)
> + return 0;
> + }
> +
> my $match_allow = 0;
> my $match_deny = 0;
>
> @@ -1527,6 +1532,7 @@ sub check_host_access {
> foreach my $t (@{$self->{allow_from}}) {
> if ($t->overlaps($cip)) {
> $match_allow = 1;
> + print "$$: check_host_access: clientip allowed: ". $t->prefix() . "\n" if $self->{debug};
> last;
> }
> }
> @@ -1535,6 +1541,7 @@ sub check_host_access {
> if ($self->{deny_from}) {
> foreach my $t (@{$self->{deny_from}}) {
> if ($t->overlaps($cip)) {
> + print "$$: check_host_access: clientip denied: ". $t->prefix() . "\n" if $self->{debug};
> $match_deny = 1;
> last;
> }
> @@ -1571,6 +1578,7 @@ sub accept_connections {
> my ($pfamily, $pport, $phost) = PVE::Tools::unpack_sockaddr_in46($sin);
> ($reqstate->{peer_port}, $reqstate->{peer_host}) = ($pport, Socket::inet_ntop($pfamily, $phost));
> } else {
> + print "$$: ACCEPT connection: getpeername failed: $!\n" if $self->{debug};
> shutdown($clientfh, 1);
> next;
> }
> @@ -1619,6 +1627,7 @@ sub accept_connections {
>
> if (my $err = $@) {
> syslog('err', $err);
> + print "$$: ACCEPT connection error: $err\n" if $self->{debug};
> shutdown($clientfh, 1) if $early_err;
> $self->{end_loop} = 1;
> }
>
can we use a helper method for the printing? Something along:
my sub dprintln {
my ($line) = @_;
return if !$self->{debug};
print "worker[$$]: $line\n";
}
could maybe drop the worker prefix, but I'd say that all processes accepting connections
can be classified as workers..
If you want to get real fancy (I mean, for perl ;) you could use caller[0] to get some call
context to print.
my ($pkg, $pkgfile, $line, $sub) = caller(1);
print "worker[$$]: $sub: $line\n";
or even
print "worker[$$]: $pkg +$line: $sub: $line\n";
We could later put such a helper in PVE::Tools and add to EXPORT_OK, could be helpful,
may want to add some bells n' whistels (control flags?) then - but that's out of scope
for this series.
[0]: https://perldoc.perl.org/functions/caller
prev parent reply other threads:[~2020-12-04 6:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-03 18:43 [pve-devel] [PATCH http-server 0/3] improve error handling in accept_connections Stoiko Ivanov
2020-12-03 18:43 ` [pve-devel] [PATCH http-server 1/3] accept-phase: fix conn_count "leak" Stoiko Ivanov
2020-12-04 7:41 ` Thomas Lamprecht
2020-12-03 18:43 ` [pve-devel] [PATCH http-server 2/3] accept-phase: shutdown socket on early error Stoiko Ivanov
2020-12-03 18:43 ` [pve-devel] [PATCH http-server 3/3] add debug log for problems during accept Stoiko Ivanov
2020-12-04 6:37 ` Thomas Lamprecht [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f6e09680-c3d6-a453-6c55-7666d0c6ed26@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
--cc=s.ivanov@proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal