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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: text/plain
Charset: utf8
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 545
Download (untitled) / with headers
text/plain 545b
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
Received: from 17h.bestpractical.com (diesel.bestpractical.com [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id 2FCD019B81E0; Mon, 27 Jul 2009 16:46:40 -0400 (EDT)
Received: by 17h.bestpractical.com (Postfix, from userid 501) id 161C28E0888; Mon, 27 Jul 2009 16:46:39 -0400 (EDT)
Delivered-To: cpan-bug+HTTP-Server-Simple [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #48249] Getting port number from PID does not work well on Win32
MIME-Version: 1.0
User-Agent: Mutt/1.5.20 (2009-06-14)
Return-Path: <jesse [...] bestpractical.com>
In-Reply-To: <rt-3.6.HEAD-14916-1248725909-1392.48249-4-0 [...] rt.cpan.org>
X-Original-To: bug-HTTP-Server-Simple [...] rt.cpan.org
Content-Disposition: inline
Date: Mon, 27 Jul 2009 16:46:39 -0400
References: <RT-Ticket-48249 [...] rt.cpan.org> <rt-3.6.HEAD-14916-1248725909-1392.48249-4-0 [...] rt.cpan.org>
Message-ID: <20090727204638.GB88188 [...] 173-125-80-232.pools.spcsdns.net>
Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="UHN/qo2QbUvPLonB"
To: K MX via RT <bug-HTTP-Server-Simple [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
RT-Message-ID: <rt-3.6.HEAD-14916-1248727606-591.48249-0-0 [...] rt.cpan.org>
Content-Length: 0
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: utf-8
Content-Length: 1115
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 >
Content-Type: application/pgp-signature
Content-Disposition: inline
Content-Length: 194
Download (untitled)
application/pgp-signature 194b

Message body not shown because it is not plain text.

MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
Content-Type: multipart/mixed; boundary="----------=_1248731616-14916-90"
Message-ID: <rt-3.6.HEAD-14916-1248731616-146.48249-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 407
Download (untitled) / with headers
text/plain 407b
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
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1248731549-14916-89"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: text/x-diff; name="HTTP-Server-Simple_patch.diff"
Content-Disposition: inline; filename="HTTP-Server-Simple_patch.diff"
Content-Transfer-Encoding: binary
Content-Length: 1805
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" );
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-14916-1248731616-146.48249-5-0 [...] rt.cpan.org>
Content-Disposition: inline
References: <RT-Ticket-48249 [...] rt.cpan.org> <rt-3.6.HEAD-14916-1248731616-146.48249-5-0 [...] rt.cpan.org>
Message-ID: <20090727221535.GA16813 [...] bestpractical.com>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
Received: by diesel.bestpractical.com (Postfix, from userid 1000) id 44A5919B81E0; Mon, 27 Jul 2009 18:15:35 -0400 (EDT)
Delivered-To: cpan-bug+HTTP-Server-Simple [...] diesel.bestpractical.com
User-Agent: Mutt/1.5.13 (2006-08-11)
Subject: Re: [rt.cpan.org #48249] Getting port number from PID does not work well on Win32
Return-Path: <jesse [...] bestpractical.com>
X-Original-To: bug-HTTP-Server-Simple [...] rt.cpan.org
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>
RT-Message-ID: <rt-3.6.HEAD-14916-1248732942-1142.48249-0-0 [...] rt.cpan.org>
Content-Length: 2843
Download (untitled) / with headers
text/plain 2.7k
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" > );
--
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-14916-1248732942-1142.48249-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Charset: utf8
References: <RT-Ticket-48249 [...] rt.cpan.org> <rt-3.6.HEAD-14916-1248731616-146.48249-5-0 [...] rt.cpan.org> <20090727221535.GA16813 [...] bestpractical.com> <rt-3.6.HEAD-14916-1248732942-1142.48249-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Message-ID: <rt-3.6.HEAD-14916-1248733568-61.48249-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 536
Download (untitled) / with headers
text/plain 536b
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
Received: from 17h.bestpractical.com (diesel.bestpractical.com [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id 33BE819B8350; Tue, 28 Jul 2009 15:59:37 -0400 (EDT)
Received: by 17h.bestpractical.com (Postfix, from userid 501) id 7C2798F56F7; Tue, 28 Jul 2009 15:59:13 -0400 (EDT)
Delivered-To: cpan-bug+HTTP-Server-Simple [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #48249] Getting port number from PID does not work well on Win32
MIME-Version: 1.0
User-Agent: Mutt/1.5.20 (2009-06-14)
Return-Path: <jesse [...] bestpractical.com>
In-Reply-To: <rt-3.6.HEAD-14916-1248733568-61.48249-5-0 [...] rt.cpan.org>
X-Original-To: bug-HTTP-Server-Simple [...] rt.cpan.org
Content-Disposition: inline
Date: Tue, 28 Jul 2009 15:59:13 -0400
References: <RT-Ticket-48249 [...] rt.cpan.org> <rt-3.6.HEAD-14916-1248731616-146.48249-5-0 [...] rt.cpan.org> <20090727221535.GA16813 [...] bestpractical.com> <rt-3.6.HEAD-14916-1248732942-1142.48249-5-0 [...] rt.cpan.org> <rt-3.6.HEAD-14916-1248733568-61.48249-5-0 [...] rt.cpan.org>
Message-ID: <20090728195913.GK58193 [...] 17h-2.local>
Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="VB1oQhYtJt8uuzk+"
To: kmx via RT <bug-HTTP-Server-Simple [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
RT-Message-ID: <rt-3.6.HEAD-14916-1248811199-1907.48249-0-0 [...] rt.cpan.org>
Content-Length: 0
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: utf-8
Content-Length: 796
Download (untitled) / with headers
text/plain 796b
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 >
Content-Type: application/pgp-signature
Content-Disposition: inline
Content-Length: 194
Download (untitled)
application/pgp-signature 194b

Message body not shown because it is not plain text.

MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-14916-1248811199-1907.48249-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Charset: utf8
References: <RT-Ticket-48249 [...] rt.cpan.org> <rt-3.6.HEAD-14916-1248731616-146.48249-5-0 [...] rt.cpan.org> <20090727221535.GA16813 [...] bestpractical.com> <rt-3.6.HEAD-14916-1248732942-1142.48249-5-0 [...] rt.cpan.org> <rt-3.6.HEAD-14916-1248733568-61.48249-5-0 [...] rt.cpan.org> <20090728195913.GK58193 [...] 17h-2.local> <rt-3.6.HEAD-14916-1248811199-1907.48249-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Message-ID: <rt-3.6.HEAD-14916-1248847014-1461.48249-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 216
Download (untitled) / with headers
text/plain 216b
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
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-14916-1248847014-1461.48249-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-48249 [...] rt.cpan.org> <rt-3.6.HEAD-14916-1248731616-146.48249-5-0 [...] rt.cpan.org> <20090727221535.GA16813 [...] bestpractical.com> <rt-3.6.HEAD-14916-1248732942-1142.48249-5-0 [...] rt.cpan.org> <rt-3.6.HEAD-14916-1248733568-61.48249-5-0 [...] rt.cpan.org> <20090728195913.GK58193 [...] 17h-2.local> <rt-3.6.HEAD-14916-1248811199-1907.48249-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-14916-1248847014-1461.48249-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-9675-1422893262-1407.48249-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 337
Download (untitled) / with headers
text/plain 337b
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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.