Skip Menu |

This queue is for tickets about the HTTP-Server-Simple CPAN distribution.

Report information
The Basics
Id: 48249
Status: resolved
Priority: 0/
Queue: HTTP-Server-Simple

People
Owner: Nobody in particular
Requestors: kmx [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 0.38_04

Attachments


Subject: Getting port number from PID does not work well on Win32
Hi, this RT regards: 01live.t and 04cgi.t where you obtain a tcp port number like this: my $PORT = 8000 + $$; Unfortunately under some circumstances the value of $$ could be a negative number on Win32. This happens especially after "fork" (or background() in your case) when the child process is not a real OS process but is emulated via threads and inside the perl is given virtual PID with negative value. I propose using something like this: my $PORT = 40000 + int(rand(10000)); it gets pseudorandom port between 40000-50000. -- kmx
Subject: Re: [rt.cpan.org #48249] Getting port number from PID does not work well on Win32
Date: Mon, 27 Jul 2009 16:46:39 -0400
To: K MX via RT <bug-HTTP-Server-Simple [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
The proposed sounds reasonable. Can you shoot me a patch to apply? On Mon 27.Jul'09 at 16:18:30 -0400, K MX via RT wrote: Show quoted text
> Mon Jul 27 16:18:29 2009: Request 48249 was acted upon. > Transaction: Ticket created by KMX > Queue: HTTP-Server-Simple > Subject: Getting port number from PID does not work well on Win32 > Broken in: (no value) > Severity: Important > Owner: Nobody > Requestors: KMX@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=48249 > > > > Hi, > > this RT regards: 01live.t and 04cgi.t where you obtain a tcp port number > like this: > > my $PORT = 8000 + $$; > > Unfortunately under some circumstances the value of $$ could be a > negative number on Win32. This happens especially after "fork" (or > background() in your case) when the child process is not a real OS > process but is emulated via threads and inside the perl is given virtual > PID with negative value. > > I propose using something like this: > > my $PORT = 40000 + int(rand(10000)); > > it gets pseudorandom port between 40000-50000. > > -- > kmx >
Download (untitled)
application/pgp-signature 194b

Message body not shown because it is not plain text.

Hi, please find the enclosed patch - it changes this port issue and also http://rt.cpan.org/Public/Bug/Display.html?id=42546 (see my last post approx 1 hour ago). In fact RT 42546 is for me more serious (it causes failing tests on Win32). IMPORTANT: the patch is against stable 0.38 as the latest 0.38_03 does not work for me on my Win32 box (despite the fact that it should contain Win32 fixes). -- kmx
Pouze v HTTP-Server-Simple-0.38p: blib Pouze v HTTP-Server-Simple-0.38p: Makefile Pouze v HTTP-Server-Simple-0.38p: Makefile.old Pouze v HTTP-Server-Simple-0.38p: pm_to_blib diff -u -r HTTP-Server-Simple-0.38/t/01live.t HTTP-Server-Simple-0.38p/t/01live.t --- HTTP-Server-Simple-0.38/t/01live.t 2009-01-02 17:17:28.000000000 +0100 +++ HTTP-Server-Simple-0.38p/t/01live.t 2009-07-27 23:51:06.215623600 +0200 @@ -7,7 +7,7 @@ # This script assumes that `localhost' will resolve to a local IP # address that may be bound to, -my $PORT = 8000 + $$; +my $PORT = 40000 + int(rand(10000)); use HTTP::Server::Simple; @@ -40,7 +40,7 @@ my $s=HTTP::Server::Simple::CGI->new($PORT); $s->host("localhost"); my $pid=$s->background(); - diag("started server on $pid"); + diag("started server PID=$pid"); like($pid, '/^-?\d+$/', 'pid is numeric'); select(undef,undef,undef,0.2); # wait a sec my $content=fetch("GET / HTTP/1.1", ""); diff -u -r HTTP-Server-Simple-0.38/t/04cgi.t HTTP-Server-Simple-0.38p/t/04cgi.t --- HTTP-Server-Simple-0.38/t/04cgi.t 2009-01-02 17:13:08.000000000 +0100 +++ HTTP-Server-Simple-0.38p/t/04cgi.t 2009-07-27 23:46:23.560527400 +0200 @@ -3,7 +3,7 @@ use strict; plan tests => 22; -my $PORT = 8000 + $$; +my $PORT = 40000 + int(rand(10000)); my $host = gethostbyaddr(inet_aton('localhost'), AF_INET); @@ -60,13 +60,13 @@ } like( - fetch("GET /cgitest/REQUEST_URI?foo%3Fbar",""), + fetch("GET /cgitest/REQUEST_URI?foo%3Fbar"), qr/foo%3Fbar/, "Didn't decode already" ); like( - fetch("GET /cgitest/foo%2Fbar/PATH_INFO",""), + fetch("GET /cgitest/foo%2Fbar/PATH_INFO"), qr|foo/bar|, "Did decode already" );
Subject: Re: [rt.cpan.org #48249] Getting port number from PID does not work well on Win32
Date: Mon, 27 Jul 2009 18:15:35 -0400
To: kmx via RT <bug-HTTP-Server-Simple [...] rt.cpan.org>
From: jesse <jesse [...] fsck.com>
Other windows-using folks are responsible for most of the post-0.38 changes. I don't have a windows box, nor do I know a whole lot about Windows internals. But I've had 3 different people sending me 3 different sets of conflicting bug reports and patches. What works for one person fails for another and vice-versa. This makes it really hard for me to do anything useful :/ On Mon, Jul 27, 2009 at 05:53:37PM -0400, kmx via RT wrote: Show quoted text
> Queue: HTTP-Server-Simple > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=48249 > > > Hi, > > please find the enclosed patch - it changes this port issue and also > http://rt.cpan.org/Public/Bug/Display.html?id=42546 (see my last post > approx 1 hour ago). > > In fact RT 42546 is for me more serious (it causes failing tests on Win32). > > IMPORTANT: the patch is against stable 0.38 as the latest 0.38_03 does > not work for me on my Win32 box (despite the fact that it should contain > Win32 fixes). > > -- > kmx
Show quoted text
> Pouze v HTTP-Server-Simple-0.38p: blib > Pouze v HTTP-Server-Simple-0.38p: Makefile > Pouze v HTTP-Server-Simple-0.38p: Makefile.old > Pouze v HTTP-Server-Simple-0.38p: pm_to_blib > diff -u -r HTTP-Server-Simple-0.38/t/01live.t HTTP-Server-Simple-0.38p/t/01live.t > --- HTTP-Server-Simple-0.38/t/01live.t 2009-01-02 17:17:28.000000000 +0100 > +++ HTTP-Server-Simple-0.38p/t/01live.t 2009-07-27 23:51:06.215623600 +0200 > @@ -7,7 +7,7 @@ > # This script assumes that `localhost' will resolve to a local IP > # address that may be bound to, > > -my $PORT = 8000 + $$; > +my $PORT = 40000 + int(rand(10000)); > > > use HTTP::Server::Simple; > @@ -40,7 +40,7 @@ > my $s=HTTP::Server::Simple::CGI->new($PORT); > $s->host("localhost"); > my $pid=$s->background(); > - diag("started server on $pid"); > + diag("started server PID=$pid"); > like($pid, '/^-?\d+$/', 'pid is numeric'); > select(undef,undef,undef,0.2); # wait a sec > my $content=fetch("GET / HTTP/1.1", ""); > diff -u -r HTTP-Server-Simple-0.38/t/04cgi.t HTTP-Server-Simple-0.38p/t/04cgi.t > --- HTTP-Server-Simple-0.38/t/04cgi.t 2009-01-02 17:13:08.000000000 +0100 > +++ HTTP-Server-Simple-0.38p/t/04cgi.t 2009-07-27 23:46:23.560527400 +0200 > @@ -3,7 +3,7 @@ > use strict; > > plan tests => 22; > -my $PORT = 8000 + $$; > +my $PORT = 40000 + int(rand(10000)); > > my $host = gethostbyaddr(inet_aton('localhost'), AF_INET); > > @@ -60,13 +60,13 @@ > } > > like( > - fetch("GET /cgitest/REQUEST_URI?foo%3Fbar",""), > + fetch("GET /cgitest/REQUEST_URI?foo%3Fbar"), > qr/foo%3Fbar/, > "Didn't decode already" > ); > > like( > - fetch("GET /cgitest/foo%2Fbar/PATH_INFO",""), > + fetch("GET /cgitest/foo%2Fbar/PATH_INFO"), > qr|foo/bar|, > "Did decode already" > );
--
Show quoted text
> Other windows-using folks are responsible for most of the post-0.38 > changes. I don't have a windows box, nor do I know a whole lot about > Windows internals. But I've had 3 different people sending me 3 > different sets of conflicting bug reports and patches. What works for > one person fails for another and vice-versa. This makes it really > hard for me to do anything useful :/
OK. I understand. Win32 feedback from me: 0.38 + patch above works nice on both win32 strawberry perl 5.8.9 and 5.10.0 - no failing tests. -- kmx
Subject: Re: [rt.cpan.org #48249] Getting port number from PID does not work well on Win32
Date: Tue, 28 Jul 2009 15:59:13 -0400
To: kmx via RT <bug-HTTP-Server-Simple [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
Applied, with part of the change in 0.38_02 now backed out. -jesse On Mon 27.Jul'09 at 18:26:09 -0400, kmx via RT wrote: Show quoted text
> Queue: HTTP-Server-Simple > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=48249 > >
> > Other windows-using folks are responsible for most of the post-0.38 > > changes. I don't have a windows box, nor do I know a whole lot about > > Windows internals. But I've had 3 different people sending me 3 > > different sets of conflicting bug reports and patches. What works for > > one person fails for another and vice-versa. This makes it really > > hard for me to do anything useful :/
> > OK. I understand. > > Win32 feedback from me: 0.38 + patch above works nice on both win32 > strawberry perl 5.8.9 and 5.10.0 - no failing tests. > > -- > kmx >
Download (untitled)
application/pgp-signature 194b

Message body not shown because it is not plain text.

0.38_02 does solve: fetch("GET /cgitest/foo%2Fbar/PATH_INFO... fetch("GET /cgitest/REQUEST_URI?foo%3Fbar... however does not solve newly reported -my $PORT = 8000 + $$; +my $PORT = 40000 + int(rand(10000)); -- kmx
On Wed Jul 29 01:56:54 2009, KMX wrote: Show quoted text
> 0.38_02 does solve: > fetch("GET /cgitest/foo%2Fbar/PATH_INFO... > fetch("GET /cgitest/REQUEST_URI?foo%3Fbar... > > however does not solve newly reported > -my $PORT = 8000 + $$; > +my $PORT = 40000 + int(rand(10000));
Looks like this was later fixed in 0.38_04 but not updated here -kevin