Shlomi Fish avatar Shlomi Fish committed db41fdb

Made the port allocation in t/14security.t more robust.

Comments (0)

Files changed (2)

 Revision history for Perl extension XML::LibXSLT.
 
+1.73            Sun Oct  9 17:32:30 IST 2011
+    - Possible fix for https://rt.cpan.org/Ticket/Display.html?id=71456 :
+        - made the port reservation on t/14security.t for the non-existent
+        URL more robust.
+
 1.72            Thu Oct  6 13:37:13 IST 2011
     - Moved the benchmarking code under benchmark/ so it won't be indexed
     by CPAN (Tim Brody).
     # valid. See:
     #
     # https://rt.cpan.org/Ticket/Display.html?id=52422
+    #
+    # We need to go to additional lengths to reserve a port due to:
+    # - https://rt.cpan.org/Ticket/Display.html?id=71456
+    # - http://stackoverflow.com/questions/7704228/perl-how-to-portably-reserve-a-tcp-port-so-there-will-be-a-non-available-url
+ 
+my $listen_sock = IO::Socket::INET->new(
+    Listen => 1,
+    Proto => 'tcp',
+    Blocking => 0,
+);
 
-    my $sock = IO::Socket::INET->new(
-        Proto => 'tcp',
-    );
+my $listen_port = $listen_sock->sockport();
 
-    my $port = $sock->sockport();
+my $conn_sock = IO::Socket::INET->new(
+    PeerAddr => 'localhost',
+    PeerPort => $listen_port,
+    Proto => 'tcp',
+    Blocking => 0,
+);
+
+my $port = $conn_sock->sockport();
 
 $file = "http://localhost:${port}/allow.xml";
 $doc = $parser->parse_string("<write>$file</write>");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.