Skip to content

Commit

Permalink
Replace the use of POSIX::tmpnam with File::Temp::tmpnam
Browse files Browse the repository at this point in the history
RT 105512: This POSIX::tmpnam has been deprecated in perl 5.22
  • Loading branch information
toddr committed Jun 26, 2015
1 parent b4da8b7 commit 549d1cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/connection_test.pl
Expand Up @@ -34,7 +34,7 @@ package MyPack;
use warnings;
use base qw(Net::Server);
use IO::Socket ();
use POSIX qw(tmpnam);
use File::Temp ();
use Socket qw(SOCK_DGRAM SOCK_STREAM);

sub post_bind_hook {
Expand All @@ -44,7 +44,7 @@ sub post_bind_hook {
}
}

my $socket_file = tmpnam();
my $socket_file = File::Temp::tmpnam();
$socket_file =~ s|/[^/]+$|/mysocket.file|;
my $socket_file2 = $socket_file ."2";
my $udp_port = 20204;
Expand Down
5 changes: 3 additions & 2 deletions lib/Net/Server/PreForkSimple.pm
Expand Up @@ -25,6 +25,7 @@ use strict;
use base qw(Net::Server);
use Net::Server::SIG qw(register_sig check_sigs);
use POSIX qw(WNOHANG EINTR);
use File::Temp ();
use Fcntl ();

sub net_server_type { __PACKAGE__ }
Expand Down Expand Up @@ -81,7 +82,7 @@ sub post_bind {
if (defined $prop->{'lock_file'}) {
$prop->{'lock_file_unlink'} = undef;
} else {
$prop->{'lock_file'} = eval { require File::Temp } ? File::Temp::tmpnam() : POSIX::tmpnam();
$prop->{'lock_file'} = File::Temp::tmpnam();
$prop->{'lock_file_unlink'} = 1;
}

Expand Down Expand Up @@ -407,7 +408,7 @@ parameters.
serialize (flock|semaphore
|pipe|none) undef
# serialize defaults to flock on multi_port or on Solaris
lock_file "filename" File::Temp::tempfile or POSIX::tmpnam
lock_file "filename" File::Temp::tempfile
check_for_dead \d+ 30
Expand Down
4 changes: 2 additions & 2 deletions t/UNIX_test.t
Expand Up @@ -2,7 +2,7 @@

package Net::Server::Test;
use strict;
use POSIX qw(tmpnam);
use File::Temp ();
use English qw($UID $GID);
use FindBin qw($Bin);
use lib $Bin;
Expand All @@ -22,7 +22,7 @@ sub accept {
return shift->SUPER::accept(@_);
}

my $socket_file = tmpnam; # must do before fork
my $socket_file = File::Temp::tmpnam();
my $ok = eval {
local $SIG{'ALRM'} = sub { die "Timeout\n" };
alarm $env->{'timeout'};
Expand Down

0 comments on commit 549d1cd

Please sign in to comment.