Subject: | Package built from net_server subclass has wrong startup parameters |
Date: | Mon, 2 May 2016 13:49:03 +0200 |
To: | bug-HTTP-Server-Simple [...] rt.cpan.org |
From: | larss <larsss31 [...] gmail.com> |
Hi,
when passing subclass to Net::Server to H::S::S via net_server method, a package is built and then run.
Arguments passed are the explicit port (port => $self->port) and the array of options passed to the method itself.
Problem is that, as the Net::Server “run” method is executed, it tries to parse input parameters, but the “port=>$self->port” part messes up the initialization
Here is a Data::Dumper of @_ with and without the port; in the former, package is run with
$pkg->run( port => $self->port, @_ );
$VAR1 = [
‘MyServer::NetServer0',
'port',
'8080',
{
'group' => 5001,
'max_servers' => 80,
'log_level' => 4,
'max_requests' => 1000,
'user' => 5001,
'port' => 17000
}
];
in the latter
$pkg->run( @_ );
$VAR1 = [
‘MyServer::NetServer0',
{
'group' => 5001,
'max_servers' => 80,
'log_level' => 4,
'max_requests' => 1000,
'user' => 5001,
'port' => 17000
}
];
In the former case, option passed in the hash are ignored and server is started on the 8080 port.
In the latter, everything goes as predicted, with options taken into account.
Thanks,
larss