소스 검색

fix #49 warnings

George Baugh 1 년 전
부모
커밋
93abe7ba39
3개의 변경된 파일9개의 추가작업 그리고 4개의 파일을 삭제
  1. 3 0
      conf/Changes
  2. 1 1
      dist.ini
  3. 5 3
      lib/Playwright.pm

+ 3 - 0
conf/Changes

@@ -1,5 +1,8 @@
 Revision history for Playwright
 
+1.251 2022-08-21 TEODESIAN
+    - Fix some undef value warnings in odd situations when using the --port option.
+
 1.250 2022-08-14 TEODESIAN
     - Update for playwright v1.25
     - Added ability to pass --port to spawn OR use existing pw server on provided port.

+ 1 - 1
dist.ini

@@ -1,5 +1,5 @@
 name = Playwright
-version = 1.250
+version = 1.251
 author = George S. Baugh <george@troglodyne.net>
 license = MIT
 copyright_holder = Troglodyne LLC

+ 5 - 3
lib/Playwright.pm

@@ -446,7 +446,7 @@ sub new ( $class, %options ) {
             debug   => $options{debug},
             cleanup => ( $options{cleanup} || !$options{port} ) // 1,
             pid     => _start_server( $port, $timeout, $options{debug}, $options{cleanup} // 1 ),
-            parent  => $$,
+            parent  => $$ // 'bogus', # Oh lawds, this can be undef sometimes
             timeout => $timeout,
         },
         $class
@@ -616,7 +616,8 @@ sub quit ($self) {
 
     # Prevent destructor from firing in child processes so we can do things like async()
     # This should also prevent the waitpid below from deadlocking due to two processes waiting on the same pid.
-    return unless $$ == $self->{parent} // 'bogus';
+    my $ppid = $$ // 'hokum'; # If $$ is undef both here and in the parent, let's just keep going
+    return unless $ppid == $self->{parent};
 
     # Prevent destructor from firing in the event the caller instructs it to not fire
     return unless $self->{cleanup};
@@ -659,7 +660,8 @@ sub _start_server ( $port, $timeout, $debug, $cleanup ) {
     # Check if the port is already live, and short-circuit if this is the case.
     if ( Net::EmptyPort::wait_port( $port, 1 ) ) {
         print "Re-using playwright server on port $port...\n" if $debug;
-        return;
+        # Set the PID as something bogus, we don't really care as we won't kill it
+        return "REUSE";
     }
 
     $ENV{DEBUG} = 'pw:api' if $debug;