Kaynağa Gözat

Fix #432: deal with inability to find port correctly

George S. Baugh 6 yıl önce
ebeveyn
işleme
8b83cf1d72
3 değiştirilmiş dosya ile 10 ekleme ve 14 silme
  1. 4 0
      Changes
  2. 1 1
      dist.ini
  3. 5 13
      lib/Selenium/CanStartBinary/ProbePort.pm

+ 4 - 0
Changes

@@ -1,5 +1,9 @@
 Revision history for Selenium-Remote-Driver
 
+1.35  10-21-2019 TEODESIAN
+        [BUG FIXES]
+        - Fix race condition and inability to find a port in certain circumstances when using direct driver modules.
+
 1.34   09-11-2019 TEODESIAN
         [BUG FIXES]
         - Remove .so files from Firefox lib tree to simplify CPAN RPM build tool chains

+ 1 - 1
dist.ini

@@ -1,5 +1,5 @@
 name = Selenium-Remote-Driver
-version = 1.34
+version = 1.35
 author = George S. Baugh <george@troglodyne.net>
 author = Aditya Ivaturi <ivaturi@gmail.com>
 author = Daniel Gempesaw <gempesaw@gmail.com>

+ 5 - 13
lib/Selenium/CanStartBinary/ProbePort.pm

@@ -17,19 +17,11 @@ our @EXPORT_OK = qw/find_open_port_above find_open_port probe_port/;
 =cut
 
 sub find_open_port_above {
-    my ($port) = @_;
-
-    my $free_port = wait_until {
-        if ( probe_port($port) ) {
-            $port++;
-            return 0;
-        }
-        else {
-            return $port;
-        }
-    };
-
-    return $free_port;
+    socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname("tcp"));
+    bind(SOCK, sockaddr_in(0, INADDR_ANY));
+    my $port = (sockaddr_in(getsockname(SOCK)))[0];
+    close(SOCK);
+    return $port;
 }
 
 sub find_open_port {