r4135 - in trunk/varnish-tools/perl/Varnish-API: . t
sky at projects.linpro.no
sky at projects.linpro.no
Tue Jul 14 08:58:02 CEST 2009
Author: sky
Date: 2009-07-14 08:58:01 +0200 (Tue, 14 Jul 2009)
New Revision: 4135
Modified:
trunk/varnish-tools/perl/Varnish-API/API.xs
trunk/varnish-tools/perl/Varnish-API/t/log.t
Log:
correctly do the right thing with the return value from dispatch callback -- test now correctly passes
Modified: trunk/varnish-tools/perl/Varnish-API/API.xs
===================================================================
--- trunk/varnish-tools/perl/Varnish-API/API.xs 2009-07-14 06:47:31 UTC (rev 4134)
+++ trunk/varnish-tools/perl/Varnish-API/API.xs 2009-07-14 06:58:01 UTC (rev 4135)
@@ -12,6 +12,8 @@
dispatch_callback(void *priv, enum shmlogtag tag, unsigned fd, unsigned len,
unsigned spec, const char *ptr) {
dSP;
+ int count;
+ int rv;
ENTER;
SAVETMPS;
@@ -21,10 +23,13 @@
XPUSHs(sv_2mortal(newSViv(spec)));
XPUSHs(sv_2mortal(newSVpv(ptr,0)));
PUTBACK;
- call_sv((SV*) priv, G_VOID);
+ count = call_sv((SV*) priv, G_SCALAR);
+ SPAGAIN;
+ rv = POPi;
+ PUTBACK;
FREETMPS;
LEAVE;
- return (1);
+ return (rv);
}
MODULE = Varnish::API PACKAGE = Varnish::API
Modified: trunk/varnish-tools/perl/Varnish-API/t/log.t
===================================================================
--- trunk/varnish-tools/perl/Varnish-API/t/log.t 2009-07-14 06:47:31 UTC (rev 4134)
+++ trunk/varnish-tools/perl/Varnish-API/t/log.t 2009-07-14 06:58:01 UTC (rev 4135)
@@ -1,30 +1,23 @@
-use Test::More tests => 2;
+use Test::More tests => 4;
BEGIN { use_ok('Varnish::API') };
use Devel::Peek;
-my $vd = Varnish::API::VSL_New;
-#print Dump($vd);
-my $foo = Varnish::API::VSL_Name();
+use Sys::Hostname qw(hostname);
-Varnish::API::VSL_OpenLog($vd, "varnish1");
+my $host = hostname;
-my $blah = \$vd;
+my $vd = Varnish::API::VSL_New();
+Varnish::API::VSL_OpenLog($vd, $host);
-my $i = 1;
-while(1) {
- Varnish::API::VSL_Dispatch($vd, sub {});
- $i++;
- unless($i % 10000) { print "$i\n" }
+Varnish::API::VSL_Dispatch($vd, sub { ok(1); return 1});
+
+{
+ my $i = 0;
+ Varnish::API::VSL_Dispatch($vd, sub {
+ ok(1);
+ return $i++;
+ });
}
-
-#ub { print join(" -- ", @_); print "\n"}) }
-
-#for(1..100) {
-#print Dump($blah);
-#my $blah = Varnish::API::VSL_NextLog($vd);
-#print Dump($blah);
-#print "$blah\n";
-#}
More information about the varnish-commit
mailing list