Skip Menu |
 

This queue is for tickets about the IO-Socket-IP CPAN distribution.

Report information
The Basics
Id: 101174
Status: resolved
Priority: 0/
Queue: IO-Socket-IP

People
Owner: Nobody in particular
Requestors: oleg [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.35



Subject: No reason to use CORE::
Download (untitled) / with headers
text/plain 816b
There is no reason to use CORE::connect or CORE::socket inside IO::Socket::IP. And this cause problems for modules, like IO::Socket::Socks::Wrapper, which wants to override CORE::connect() globally. Perl always prefers CORE:: functions, so when we write connect($socket, $name) perl thinks about CORE::connect. This simple test confirms this idea use strict; use warnings; use Socket; package A; sub new { socket(my $self, Socket::PF_INET, Socket::SOCK_STREAM, getprotobyname("tcp")); bless $self, $_[0]; } sub connect { warn "A::connect"; } package B; our @ISA = 'A'; sub connect { my ($self, $name) = @_; warn "B::connect"; connect($self, $name); } package main; my $b = B->new; $b->connect(scalar sockaddr_in(80, inet_aton('google.com'))) or die $!; __END__ And attached patch fixes this issue
Subject: io-socket-ip-core.patch
--- lib/IO/Socket/IP.pm.orig 2014-12-28 22:23:36.482944376 +0600 +++ lib/IO/Socket/IP.pm 2014-12-28 22:25:24.983474803 +0600 @@ -664,11 +664,11 @@ # implemented, so we'll have to reinvent it here my $timeout = ${*$self}{'io_socket_timeout'}; - return CORE::connect( $self, $addr ) unless defined $timeout; + return connect( $self, $addr ) unless defined $timeout; my $was_blocking = $self->blocking( 0 ); - my $err = defined CORE::connect( $self, $addr ) ? 0 : $!+0; + my $err = defined connect( $self, $addr ) ? 0 : $!+0; if( !$err ) { # All happy @@ -714,7 +714,7 @@ # (still in progress). This even works on MSWin32. my $addr = ${*$self}{io_socket_ip_infos}[${*$self}{io_socket_ip_idx}]{peeraddr}; - if( CORE::connect( $self, $addr ) or $! == EISCONN ) { + if( connect( $self, $addr ) or $! == EISCONN ) { delete ${*$self}{io_socket_ip_connect_in_progress}; $! = 0; return 1; @@ -899,7 +899,7 @@ return $self->SUPER::socket(@_) if not defined $self->fileno; # I hate core prototypes sometimes... - CORE::socket( my $tmph, $_[0], $_[1], $_[2] ) or return undef; + socket( my $tmph, $_[0], $_[1], $_[2] ) or return undef; dup2( $tmph->fileno, $self->fileno ) or die "Unable to dup2 $tmph onto $self - $!"; }
Thanks, fixed, will be in next version. -- Paul Evans
Released -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.