[jifty-devel] Jifty::Logger and Jifty::Script::Schema problems on Win32

Ishigaki Kenichi ishigaki at tcool.org
Thu May 18 02:49:18 EDT 2006

Hi. Jifty::Logger and Jifty::Script::Schema have problems on Win32.
::Schema problem is rather simple: Win32 complains while jifty tries
to unlink an open file/database. So, below patch would be enough.

Index: trunk/lib/Jifty/Script/Schema.pm
--- Schema.pm	(revision 1076)
+++ Schema.pm	(working copy)
@@ -443,7 +443,9 @@
         if ( $self->{'print'} ) {
             print "DROP DATABASE $database;\n";
         } elsif ( $driver eq 'SQLite' ) {
-            unlink($database);
+            # Win32 complains if you try to unlink an open file/database
+            $handle->disconnect;
+            unlink($database) or die("dropping database failed: $!");
         } else {
             $handle->simple_query("DROP DATABASE $database");

::Logger problem seems more complex. At the moment below patch seems
to clear the problem, but I'm not sure this is the right patch.

Index: trunk/lib/Jifty/Logger.pm
--- Logger.pm	(revision 1076)
+++ Logger.pm	(working copy)
@@ -72,7 +72,14 @@
         # If the logger has been taken apart by global destruction,
         # don't try to use it to log warnings
-        $logger->warn(@_) if Log::Log4perl->initialized;
+        if ( Log::Log4perl->initialized ) {
+            if ($^O eq 'MSWin32') {
+                Log::Log4perl->get_logger->warn(@_);
+            }
+            else {
+                $logger->warn(@_);
+            }
+        }
     return $self;

The problem without this patch is, when Jifty::Script::Schema calls
Jifty->new internally (in the eval block) and subsequently
Jifty::Logger->new (second time), Jifty on Win32 fails to return to
the right place while setting $SIG{__WARN__}. I'm not sure why this
happens, and no problem at the first time. Only at the second time,
it goes somewhere and fails to execute the next 'return $self'.

Insert "warn"s before and after the $SIG{__WARN__} sentence and run
some tests ('perl t/00-load.t' would be enough), and you'll see
what's happening on Win32.

Any ideas?

Anyway, though problematic, with these patches Jifty on Win32 would
pass much more tests, maybe almost all but the ones that need
Test::HTTP::Server::Simple (that I haven't force-installed yet).


More information about the jifty-devel mailing list