[Dancer-users] mime types

Oleg A. Mamontov oleg at mamontov.net
Thu Feb 10 16:37:50 CET 2011


Hello.

I discovered some problems with Dancer::MIME under
Starman::Server (type Net::Server::PreFork).

After some debugging i found that MIME::Types (used in Dancer::MIME)
read and parse mime types from it DATA handle.
This handle is opening by Perl during module load procedure. But subsequent
reads occured in &MIME::Types::init (which called from constructor).

In Dancer flow it occurs after fork, in different processes concurrently.
Thereby some processes had invalid MIME data.

I propose three different solutions:

1. Remove MIME::Types from Dancer::MIME completely :)

2. Explicitly call &MIME::Types::init early (before fork):
   
   package Dancer::MIME;
   use strict;
   use warnings;
   use base 'Dancer::Object::Singleton';
   use MIME::Types;

   MIME::Types->init;

3. Use MIME::Types later (in &Dancer::MIME::init):

   sub init {
     my ($class, $instance) = @_;
     eval "use MIME::Types";
     $instance->mime_type(MIME::Types->new(only_complete => 1));
     $instance->aliases({});
   }


What's more properly?

Thank you.

-- 
Cheers,
Oleg A. Mamontov

mailto:  oleg at mamontov.net

jabber:  lonerr at charla.mamontov.net
icq uin: 79-521-617
cell:    +7-903-798-1352



More information about the Dancer-users mailing list