[djabberd] kane, r799: r6897@db-dev1: josboum | 2008-08-06 19...

Brad Fitzpatrick brad at danga.com
Wed Aug 6 18:58:27 UTC 2008


On Wed, Aug 6, 2008 at 10:44 AM, <commits at code.sixapart.com> wrote:

>  r6897 at db-dev1:  josboum | 2008-08-06 19:40:36 +0200
>  * Improve diagnostics when running under debug mode; this logging is
> somewhat expensive, and
>   it might be a good idea to only compute the strings if the server is
> running in debug mode.
>  * Add data::dumper + indentation to djabberd-test.pl to speed up debugging
> in test mode
>
>
>
> _U  trunk/
> U   trunk/DJabberd/lib/DJabberd/Callback.pm
> U   trunk/DJabberd/lib/DJabberd/VHost.pm
> U   trunk/DJabberd/t/lib/djabberd-test.pl
>
>
>
> Property changes on: trunk
> ___________________________________________________________________
> Name: svk:merge
>   - 02e31fea-a713-0410-9bb5-81a53d0f95f7:/djabberd-trunk:4879
> 1b5ff1af-660f-0410-86e2-35bade70ffec:/trunk/djabberd:61
> 391f84f8-cfa2-4f6b-a47d-f52c5dc88d86:/local/sixapart/djabberd-trunk:6534
> 54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/groupchat:328
> 54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/local:667
> c548c595-0a51-0410-a370-acbe0a8988c9:/local/sixapart/djabberd/trunk:6896
>   + 02e31fea-a713-0410-9bb5-81a53d0f95f7:/djabberd-trunk:4879
> 1b5ff1af-660f-0410-86e2-35bade70ffec:/trunk/djabberd:61
> 391f84f8-cfa2-4f6b-a47d-f52c5dc88d86:/local/sixapart/djabberd-trunk:6534
> 54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/groupchat:328
> 54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/local:667
> c548c595-0a51-0410-a370-acbe0a8988c9:/local/sixapart/djabberd/trunk:6897
>
> Modified: trunk/DJabberd/lib/DJabberd/Callback.pm
> ===================================================================
> --- trunk/DJabberd/lib/DJabberd/Callback.pm     2008-08-06 17:44:20 UTC
> (rev 798)
> +++ trunk/DJabberd/lib/DJabberd/Callback.pm     2008-08-06 17:44:33 UTC
> (rev 799)
> @@ -3,6 +3,8 @@
>  use Carp qw(croak);
>  our $AUTOLOAD;
>
> +our $logger = DJabberd::Log->get_logger();
> +
>  sub new {
>     #my ($class, $meths) = @_;
>     # TODO: track where it was defined at, in debug mode?
> @@ -34,6 +36,12 @@
>     # ignore perl-generated methods
>     return unless $meth =~ /[a-z]/;
>
> +    ### XXX this logging is somewhat expensive. Logging should probably
> +    ### only be done if loglevel is set to debug --kane
> +    {   my @c = caller;
> +        $logger->debug( '$callback->'."$meth( @_ ) has been called from
> $c[1]:$c[2]" );
> +    }
> +
>     if ($self->{_has_been_called}++) {
>         warn "Callback called twice.  ignoring.\n";
>         return;
>
> Modified: trunk/DJabberd/lib/DJabberd/VHost.pm
> ===================================================================
> --- trunk/DJabberd/lib/DJabberd/VHost.pm        2008-08-06 17:44:20 UTC
> (rev 798)
> +++ trunk/DJabberd/lib/DJabberd/VHost.pm        2008-08-06 17:44:33 UTC
> (rev 799)
> @@ -237,13 +237,28 @@
>     }
>     push @hooks, $fallback if $fallback;
>
> -    my ($cb, $try_another);  # pre-declared here so they're captured by
> closures below
> +    # pre-declared here so they're captured by closures below
> +    my ($cb, $try_another, $depth);
> +    my $hook_count = scalar @hooks;
> +
>     my $stopper = sub {
>         $try_another = undef;
>     };
>     $try_another = sub {
>         my $hk = shift @hooks
>             or return;
> +
> +        $depth++;
> +
> +        ### XXX this logging is somewhat expensive. Logging should
> probably
> +        ### only be done if loglevel is set to debug --kane


So don't check this in.  Your commit message even says that it's
unnecessarily slow and should only be computed when debug mode is on.  So do
that first, before you commit to trunk.  Trunk should be stable/good.


>
> +        {   use B;


use B at top of the file, not here.  use is compile-time anyway, so this
buys nothing.  and import it as use B (); just to be clear that you're
importing no symbols.


> +            my $cv = B::svref_2object( $hk );


kill the spaces around the parens.



>
> +            $logger->debug(
> +                "For phase [@$phase] invoking hook $depth of $hook_count
> defined at: ".
> +                $cv->FILE .':'. $cv->ROOT->first->first->line
> +            );
> +        }
>
>         $cb->{_has_been_called} = 0;  # cheating version of: $cb->reset;
>         $hk->($self || $hook_inv,
>
> Modified: trunk/DJabberd/t/lib/djabberd-test.pl
> ===================================================================
> --- trunk/DJabberd/t/lib/djabberd-test.pl       2008-08-06 17:44:20 UTC
> (rev 798)
> +++ trunk/DJabberd/t/lib/djabberd-test.pl       2008-08-06 17:44:33 UTC
> (rev 799)
> @@ -167,6 +167,9 @@
>  use overload
>     '""' => \&as_string;
>
> +use Data::Dumper    qw[Dumper];
> +local $Data::Dumper::Indent = 1;
> +
>  our $PLUGIN_CB;
>  our $VHOST_CB;
>  our @SUBDOMAINS;
> @@ -316,6 +319,9 @@
>  use overload
>     '""' => \&as_string;
>
> +use Data::Dumper    qw[Dumper];
> +local $Data::Dumper::Indent = 1;
> +
>  sub resource {
>     return $_[0]{resource} ||= ($ENV{UNICODE_RESOURCE} ? "test\xe2\x80\x99s
> computer" : "testsuite_with_gibberish:'\"");
>  }
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/djabberd/attachments/20080806/13435fc1/attachment.html 


More information about the Djabberd mailing list