[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

[PATCH 5.5.63] warn on flock() on closed handle



See <URL:http://www.deja.com/getdoc.xp?AN=571930322&fmt=text> and the
thread containing it.

diff -rc perl5.005_63.dist/pod/perldiag.pod perl5.005_63/pod/perldiag.pod
*** perl5.005_63.dist/pod/perldiag.pod	Wed Dec  8 00:23:13 1999
--- perl5.005_63/pod/perldiag.pod	Thu Jan 13 09:39:03 2000
***************
*** 3557,3559 ****
--- 3557,3565 ----
  
  =back
  
+ =item Flock on closed filehandle
+ 
+ (W) The filehandle you're attempting flock() got itself closed some time
+ before now.  Check your logic flow.
+ 
+ =back
diff -rc perl5.005_63.dist/pp_sys.c perl5.005_63/pp_sys.c
*** perl5.005_63.dist/pp_sys.c	Wed Dec  8 00:23:14 1999
--- perl5.005_63/pp_sys.c	Thu Jan 13 09:36:43 2000
***************
*** 1986,1993 ****
  	(void)PerlIO_flush(fp);
  	value = (I32)(PerlLIO_flock(PerlIO_fileno(fp), argtype) >= 0);
      }
!     else
  	value = 0;
      PUSHi(value);
      RETURN;
  #else
--- 1986,1997 ----
  	(void)PerlIO_flush(fp);
  	value = (I32)(PerlLIO_flock(PerlIO_fileno(fp), argtype) >= 0);
      }
!     else {
  	value = 0;
+ 	if (ckWARN(WARN_CLOSED))
+ 	    Perl_warner(aTHX_ WARN_CLOSED, "Flock on closed filehandle");
+     }
+ 
      PUSHi(value);
      RETURN;
  #else
diff -rc perl5.005_63.dist/t/pragma/warn/pp_sys perl5.005_63/t/pragma/warn/pp_sys
*** perl5.005_63.dist/t/pragma/warn/pp_sys	Mon Sep  6 13:39:08 1999
--- perl5.005_63/t/pragma/warn/pp_sys	Thu Jan 13 09:51:51 2000
***************
*** 66,71 ****
--- 66,75 ----
      getsockname STDIN;
      getpeername STDIN;
  
+   flock() on closed fd				[pp_flock]
+     close STDIN;
+     flock STDIN, 8;
+ 
    warn(warn_nl, "stat");			[pp_stat]
  
    Test on unopened file <%s>
***************
*** 167,172 ****
--- 171,185 ----
  EXPECT
  Syswrite on closed filehandle at - line 4.
  ########
+ # pp_sys.c [pp_flock]
+ use warnings 'closed' ;
+ close STDIN;
+ flock STDIN, 8;
+ no warnings 'closed' ;
+ flock STDIN, 8;
+ EXPECT
+ Flock on closed filehandle at - line 4.
+ ########
  # pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
  use warnings 'io' ;
  use Config; 
***************
*** 198,203 ****
--- 211,217 ----
  getsockopt STDIN, 1,2;
  getsockname STDIN;
  getpeername STDIN;
+ flock STDIN, 8;
  no warnings 'io' ;
  send STDIN, "fred", 1;
  bind STDIN, "fred" ;
***************
*** 209,214 ****
--- 223,229 ----
  getsockopt STDIN, 1,2;
  getsockname STDIN;
  getpeername STDIN;
+ flock STDIN, 8;
  EXPECT
  Send on closed socket at - line 22.
  bind() on closed fd at - line 23.
***************
*** 220,225 ****
--- 235,241 ----
  [gs]etsockopt() on closed fd at - line 29.
  get{sock, peer}name() on closed fd at - line 30.
  get{sock, peer}name() on closed fd at - line 31.
+ Flock on closed filehandle at - line 32.
  ########
  # pp_sys.c [pp_stat]
  use warnings 'newline' ;

End of Patch.


[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]