<div dir="ltr"><br><br><div class="gmail_quote">On Wed, Aug 6, 2008 at 10:44 AM,  <span dir="ltr">&lt;<a href="mailto:commits@code.sixapart.com">commits@code.sixapart.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&nbsp;r6897@db-dev1: &nbsp;josboum | 2008-08-06 19:40:36 +0200<br>
&nbsp;* Improve diagnostics when running under debug mode; this logging is somewhat expensive, and<br>
 &nbsp; it might be a good idea to only compute the strings if the server is running in debug mode.<br>
&nbsp;* Add data::dumper + indentation to djabberd-test.pl to speed up debugging in test mode<br>
<br>
<br>
<br>
_U &nbsp;trunk/<br>
U &nbsp; trunk/DJabberd/lib/DJabberd/Callback.pm<br>
U &nbsp; trunk/DJabberd/lib/DJabberd/VHost.pm<br>
U &nbsp; trunk/DJabberd/t/lib/djabberd-test.pl<br>
<br>
<br>
<br>
Property changes on: trunk<br>
___________________________________________________________________<br>
Name: svk:merge<br>
 &nbsp; - 02e31fea-a713-0410-9bb5-81a53d0f95f7:/djabberd-trunk:4879<br>
1b5ff1af-660f-0410-86e2-35bade70ffec:/trunk/djabberd:61<br>
391f84f8-cfa2-4f6b-a47d-f52c5dc88d86:/local/sixapart/djabberd-trunk:6534<br>
54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/groupchat:328<br>
54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/local:667<br>
c548c595-0a51-0410-a370-acbe0a8988c9:/local/sixapart/djabberd/trunk:6896<br>
 &nbsp; + 02e31fea-a713-0410-9bb5-81a53d0f95f7:/djabberd-trunk:4879<br>
1b5ff1af-660f-0410-86e2-35bade70ffec:/trunk/djabberd:61<br>
391f84f8-cfa2-4f6b-a47d-f52c5dc88d86:/local/sixapart/djabberd-trunk:6534<br>
54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/groupchat:328<br>
54bb65a0-b99f-4f2b-b22a-e47d41dc43c7:/local:667<br>
c548c595-0a51-0410-a370-acbe0a8988c9:/local/sixapart/djabberd/trunk:6897<br>
<br>
Modified: trunk/DJabberd/lib/DJabberd/Callback.pm<br>
===================================================================<br>
--- trunk/DJabberd/lib/DJabberd/Callback.pm &nbsp; &nbsp; 2008-08-06 17:44:20 UTC (rev 798)<br>
+++ trunk/DJabberd/lib/DJabberd/Callback.pm &nbsp; &nbsp; 2008-08-06 17:44:33 UTC (rev 799)<br>
@@ -3,6 +3,8 @@<br>
&nbsp;use Carp qw(croak);<br>
&nbsp;our $AUTOLOAD;<br>
<br>
+our $logger = DJabberd::Log-&gt;get_logger();<br>
+<br>
&nbsp;sub new {<br>
 &nbsp; &nbsp; #my ($class, $meths) = @_;<br>
 &nbsp; &nbsp; # TODO: track where it was defined at, in debug mode?<br>
@@ -34,6 +36,12 @@<br>
 &nbsp; &nbsp; # ignore perl-generated methods<br>
 &nbsp; &nbsp; return unless $meth =~ /[a-z]/;<br>
<br>
+ &nbsp; &nbsp;### XXX this logging is somewhat expensive. Logging should probably<br>
+ &nbsp; &nbsp;### only be done if loglevel is set to debug --kane<br>
+ &nbsp; &nbsp;{ &nbsp; my @c = caller;<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;$logger-&gt;debug( &#39;$callback-&gt;&#39;.&quot;$meth( @_ ) has been called from $c[1]:$c[2]&quot; );<br>
+ &nbsp; &nbsp;}<br>
+<br>
 &nbsp; &nbsp; if ($self-&gt;{_has_been_called}++) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; warn &quot;Callback called twice. &nbsp;ignoring.\n&quot;;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; return;<br>
<br>
Modified: trunk/DJabberd/lib/DJabberd/VHost.pm<br>
===================================================================<br>
--- trunk/DJabberd/lib/DJabberd/VHost.pm &nbsp; &nbsp; &nbsp; &nbsp;2008-08-06 17:44:20 UTC (rev 798)<br>
+++ trunk/DJabberd/lib/DJabberd/VHost.pm &nbsp; &nbsp; &nbsp; &nbsp;2008-08-06 17:44:33 UTC (rev 799)<br>
@@ -237,13 +237,28 @@<br>
 &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; push @hooks, $fallback if $fallback;<br>
<br>
- &nbsp; &nbsp;my ($cb, $try_another); &nbsp;# pre-declared here so they&#39;re captured by closures below<br>
+ &nbsp; &nbsp;# pre-declared here so they&#39;re captured by closures below<br>
+ &nbsp; &nbsp;my ($cb, $try_another, $depth);<br>
+ &nbsp; &nbsp;my $hook_count = scalar @hooks;<br>
+<br>
 &nbsp; &nbsp; my $stopper = sub {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; $try_another = undef;<br>
 &nbsp; &nbsp; };<br>
 &nbsp; &nbsp; $try_another = sub {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; my $hk = shift @hooks<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; or return;<br>
+<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;$depth++;<br>
+<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;### XXX this logging is somewhat expensive. Logging should probably<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;### only be done if loglevel is set to debug --kane</blockquote><div><br>So don&#39;t check this in.&nbsp; Your commit message even says that it&#39;s unnecessarily slow and should only be computed when debug mode is on.&nbsp; So do that first, before you commit to trunk.&nbsp; Trunk should be stable/good.<br>
&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &nbsp; use B;</blockquote><div><br>use B at top of the file, not here.&nbsp; use is compile-time anyway, so this buys nothing.&nbsp; and import it as use B (); just to be clear that you&#39;re importing no symbols.<br><br></div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;my $cv = B::svref_2object( $hk );</blockquote><div><br>kill the spaces around the parens.<br><br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$logger-&gt;debug(<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;For phase [@$phase] invoking hook $depth of $hook_count defined at: &quot;.<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$cv-&gt;FILE .&#39;:&#39;. $cv-&gt;ROOT-&gt;first-&gt;first-&gt;line<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; $cb-&gt;{_has_been_called} = 0; &nbsp;# cheating version of: $cb-&gt;reset;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; $hk-&gt;($self || $hook_inv,<br>
<br>
Modified: trunk/DJabberd/t/lib/djabberd-test.pl<br>
===================================================================<br>
--- trunk/DJabberd/t/lib/djabberd-test.pl &nbsp; &nbsp; &nbsp; 2008-08-06 17:44:20 UTC (rev 798)<br>
+++ trunk/DJabberd/t/lib/djabberd-test.pl &nbsp; &nbsp; &nbsp; 2008-08-06 17:44:33 UTC (rev 799)<br>
@@ -167,6 +167,9 @@<br>
&nbsp;use overload<br>
 &nbsp; &nbsp; &#39;&quot;&quot;&#39; =&gt; \&amp;as_string;<br>
<br>
+use Data::Dumper &nbsp; &nbsp;qw[Dumper];<br>
+local $Data::Dumper::Indent = 1;<br>
+<br>
&nbsp;our $PLUGIN_CB;<br>
&nbsp;our $VHOST_CB;<br>
&nbsp;our @SUBDOMAINS;<br>
@@ -316,6 +319,9 @@<br>
&nbsp;use overload<br>
 &nbsp; &nbsp; &#39;&quot;&quot;&#39; =&gt; \&amp;as_string;<br>
<br>
+use Data::Dumper &nbsp; &nbsp;qw[Dumper];<br>
+local $Data::Dumper::Indent = 1;<br>
+<br>
&nbsp;sub resource {<br>
 &nbsp; &nbsp; return $_[0]{resource} ||= ($ENV{UNICODE_RESOURCE} ? &quot;test\xe2\x80\x99s computer&quot; : &quot;testsuite_with_gibberish:&#39;\&quot;&quot;);<br>
&nbsp;}<br>
<br>
<br>
</blockquote></div><br></div>