Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen to socket does not return when host is undefined or 0.0.0.0. #11243

Closed
p5pRT opened this issue Apr 8, 2011 · 8 comments
Closed

Listen to socket does not return when host is undefined or 0.0.0.0. #11243

p5pRT opened this issue Apr 8, 2011 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 8, 2011

Migrated from rt.perl.org#88080 (status was 'resolved')

Searchable as RT88080$

@p5pRT
Copy link
Author

p5pRT commented Apr 8, 2011

From Bo.Johansson@lsn.se

Created by bo.johansson@lsn.se

The perl function listen does not return when host is undefined or 0.0.0.0.
Sometimes it also gets Windows 7 in unstable state and normal shut down is impossible.

Example​: This is setup_listener from HTTP-Server-Simple-0.44/lib/HTTP/Server/Simple.pm

sub setup_listener {
  my $self = shift;

  my $tcp = getprotobyname('tcp');
  socket( HTTPDaemon, PF_INET, SOCK_STREAM, $tcp ) or croak "socket​: $!";
  setsockopt( HTTPDaemon, SOL_SOCKET, SO_REUSEADDR, pack( "l", 1 ) )
  or warn "setsockopt​: $!";
  bind( HTTPDaemon,
  sockaddr_in(
  $self->port(),
  ( $self->host
  ? inet_aton( $self->host )
  : INADDR_ANY
  )
  )
  )
  or croak "bind to @​{[$self->host||'*']}​:@​{[$self->port]}​: $!";
  listen( HTTPDaemon, SOMAXCONN ) or croak "listen​: $!";
}

If $self->host is undefined or '0.0.0.0' the call to listen does not return.
Sometimes it gets Windows 7 in unstable state and

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.12.2:

Configured by 1 at Fri Nov  5 08:33:05 2010.

Summary of my perl5 (revision 5 version 12 subversion 2) configuration:
   
  Platform:
    osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
    uname='Win32 strawberryperl 5.12.2.0 #1 Fri Nov  5 05:17:27 2010 i386'
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags =' -s -O2 -DWIN32 -DHAVE_DES_FCRYPT  -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -mms-bitfields -DPERL_MSVCRT_READFIX',
    optimize='-s -O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='4.4.3', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long long', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags ='-s -L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib"'
    libpth=C:\strawberry\c\lib C:\strawberry\c\i686-w64-mingw32\lib
    libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=, so=dll, useshrplib=true, libperl=libperl512.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -s -L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib"'

Locally applied patches:
    


@INC for perl 5.12.2:
    C:/strawberry/perl/site/lib
    C:/strawberry/perl/vendor/lib
    C:/strawberry/perl/lib
    .


Environment for perl 5.12.2:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program Files\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\ArcSoft\Bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;c:\Parrot-2.8.0\bin;S:\ins\ant\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;c:\Program Files\Emacs\EmacsW32\gnuwin32\bin\;c:\Program Files\Java\jdk1.6.0_16\bin;C:\hp\bin\Python;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Graphviz2.26.3\bin;C:\strawberry\c\bin;C:\strawberry\perl\bin;C:\gnuwin32\bin;C:\Parrot-2.8.0\bin;C:\Parrot-2.8.0\bin;C:\Program Files\Windows Live\Shared;C:\Program Files\QuickTime\QTSystem\;C:\strawberry\perl\site\bin;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files\Git\cmd
    PERL_BADLANG (unset)
    SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Dec 31, 2016

From @jkeenan

On Fri, 08 Apr 2011 08​:47​:19 GMT, boilund wrote​:

This is a bug report for perl from bo.johansson@​lsn.se,
generated with the help of perlbug 1.39 running under perl 5.12.2.

-----------------------------------------------------------------
[Please describe your issue here]

The perl function listen does not return when host is undefined or
0.0.0.0.
Sometimes it also gets Windows 7 in unstable state and normal shut
down is impossible.

Example​: This is setup_listener from HTTP-Server-Simple-
0.44/lib/HTTP/Server/Simple.pm

sub setup_listener {
my $self = shift;

my $tcp = getprotobyname('tcp');
socket( HTTPDaemon, PF_INET, SOCK_STREAM, $tcp ) or croak "socket​:
$!";
setsockopt( HTTPDaemon, SOL_SOCKET, SO_REUSEADDR, pack( "l", 1 ) )
or warn "setsockopt​: $!";
bind( HTTPDaemon,
sockaddr_in(
$self->port(),
( $self->host
? inet_aton( $self->host )
: INADDR_ANY
)
)
)
or croak "bind to @​{[$self->host||'*']}​:@​{[$self->port]}​: $!";
listen( HTTPDaemon, SOMAXCONN ) or croak "listen​: $!";
}

If $self->host is undefined or '0.0.0.0' the call to listen does not
return.
Sometimes it gets Windows 7 in unstable state and

Can the problem with Perl function 'listen' (assuming there *is* a problem) be demonstrated apart from this use in HTTP​::Server​::Simple?

The code provided is not sufficient to reproduce the problem (at least by a person not already familiar with that module).

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Dec 31, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jan 1, 2017

From Bo.Johansson@lsn.se

Hej!

I have run​:

  use strict;
  use warnings;

  use HTTP​::Server​::Simple;

  my $server = HTTP​::Server​::Simple->new();
  $server->host( undef );
  #$server->host( '0.0.0.0' );
  $server->run();

Using "$server->host( undef );" or "$server->host( '0.0.0.0' );" works
with HTTP​::Server​::Simple version 0.51!

Best regards
Bo Johansson

Den 2016-12-31 kl. 16​:14, skrev James E Keenan via RT​:

On Fri, 08 Apr 2011 08​:47​:19 GMT, boilund wrote​:

This is a bug report for perl from bo.johansson@​lsn.se,
generated with the help of perlbug 1.39 running under perl 5.12.2.

-----------------------------------------------------------------
[Please describe your issue here]

The perl function listen does not return when host is undefined or
0.0.0.0.
Sometimes it also gets Windows 7 in unstable state and normal shut
down is impossible.

Example​: This is setup_listener from HTTP-Server-Simple-
0.44/lib/HTTP/Server/Simple.pm

sub setup_listener {
my $self = shift;

my $tcp = getprotobyname('tcp');
socket( HTTPDaemon, PF_INET, SOCK_STREAM, $tcp ) or croak "socket​:
$!";
setsockopt( HTTPDaemon, SOL_SOCKET, SO_REUSEADDR, pack( "l", 1 ) )
or warn "setsockopt​: $!";
bind( HTTPDaemon,
sockaddr_in(
$self->port(),
( $self->host
? inet_aton( $self->host )
: INADDR_ANY
)
)
)
or croak "bind to @​{[$self->host||'*']}​:@​{[$self->port]}​: $!";
listen( HTTPDaemon, SOMAXCONN ) or croak "listen​: $!";
}

If $self->host is undefined or '0.0.0.0' the call to listen does not
return.
Sometimes it gets Windows 7 in unstable state and

Can the problem with Perl function 'listen' (assuming there *is* a problem) be demonstrated apart from this use in HTTP​::Server​::Simple?

The code provided is not sufficient to reproduce the problem (at least by a person not already familiar with that module).

Thank you very much.

@p5pRT
Copy link
Author

p5pRT commented Jan 1, 2017

From @jkeenan

On Sun, 01 Jan 2017 10​:36​:01 GMT, boilund wrote​:

Hej!

I have run​:

use strict;
use warnings;

use HTTP​::Server​::Simple;

my $server = HTTP​::Server​::Simple->new();
$server->host( undef );
#$server->host( '0.0.0.0' );
$server->run();

Using "$server->host( undef );" or "$server->host( '0.0.0.0' );" works
with HTTP​::Server​::Simple version 0.51!

Best regards
Bo Johansson

Den 2016-12-31 kl. 16​:14, skrev James E Keenan via RT​:

On Fri, 08 Apr 2011 08​:47​:19 GMT, boilund wrote​:

This is a bug report for perl from bo.johansson@​lsn.se,
generated with the help of perlbug 1.39 running under perl 5.12.2.

-----------------------------------------------------------------
[Please describe your issue here]

The perl function listen does not return when host is undefined or
0.0.0.0.
Sometimes it also gets Windows 7 in unstable state and normal shut
down is impossible.

Example​: This is setup_listener from HTTP-Server-Simple-
0.44/lib/HTTP/Server/Simple.pm

sub setup_listener {
my $self = shift;

my $tcp = getprotobyname('tcp');
socket( HTTPDaemon, PF_INET, SOCK_STREAM, $tcp ) or croak "socket​:
$!";
setsockopt( HTTPDaemon, SOL_SOCKET, SO_REUSEADDR, pack( "l", 1 ) )
or warn "setsockopt​: $!";
bind( HTTPDaemon,
sockaddr_in(
$self->port(),
( $self->host
? inet_aton( $self->host )
: INADDR_ANY
)
)
)
or croak "bind to @​{[$self->host||'*']}​:@​{[$self->port]}​: $!";
listen( HTTPDaemon, SOMAXCONN ) or croak "listen​: $!";
}

If $self->host is undefined or '0.0.0.0' the call to listen does not
return.
Sometimes it gets Windows 7 in unstable state and

Can the problem with Perl function 'listen' (assuming there *is* a
problem) be demonstrated apart from this use in HTTP​::Server​::Simple?

The code provided is not sufficient to reproduce the problem (at
least by a person not already familiar with that module).

Thank you very much.

I modified HTTP​::Server​::Simple​::setup_listener() to capture the return value of 'listen()' before returning from the method.

#####
  my $rv = listen( HTTPDaemon, SOMAXCONN ) or croak "listen​: $!";
  return $rv;
#####

I then called your program -- with '$server->host(undef)' -- with the perl debugger and stepped through to the lines above. The value of '$rv' is '1', so listen() returned a true value.

Where the program *did* hang was in this part of subroutine '_default_run(()'​:

#####
  while ($SERVER_SHOULD_RUN) {
  local $SIG{PIPE} = 'IGNORE'; # If we don't ignore SIGPIPE, a
  # client closing the connection before we
  # finish sending will cause the server to exit
  while ( accept( my $remote = new FileHandle, HTTPDaemon ) ) {
#####

The program hung on the 2nd 'while' loop. When I hit Ctrl-C, the program resumed at the 'local $SIG{PIPE}...' line.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Jan 1, 2017

From @Leont

On Sun, Jan 1, 2017 at 11​:34 AM, Bo Johansson <bo.johansson@​lsn.se> wrote​:

Hej!

I have run​:

use strict;
use warnings;

use HTTP​::Server​::Simple;

my $server = HTTP​::Server​::Simple->new();
$server->host( undef );
#$server->host( '0.0.0.0' );
$server->run();

Using "$server->host( undef );" or "$server->host( '0.0.0.0' );" works
with HTTP​::Server​::Simple version 0.51!
Best regards
Bo Johansson

Does that mean this ticket is closable?

Leon

@p5pRT p5pRT closed this as completed Mar 28, 2017
@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2017

@iabyn - Status changed from 'open' to 'resolved'

@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2017

From @iabyn

On Sun, Jan 01, 2017 at 07​:20​:48PM +0100, Leon Timmermans wrote​:

On Sun, Jan 1, 2017 at 11​:34 AM, Bo Johansson <bo.johansson@​lsn.se> wrote​:

Hej!

I have run​:

use strict;
use warnings;

use HTTP​::Server​::Simple;

my $server = HTTP​::Server​::Simple->new();
$server->host( undef );
#$server->host( '0.0.0.0' );
$server->run();

Using "$server->host( undef );" or "$server->host( '0.0.0.0' );" works
with HTTP​::Server​::Simple version 0.51!
Best regards
Bo Johansson

Does that mean this ticket is closable?

In the absence of any further feedback, I'm closing this ticket.

--
Overhead, without any fuss, the stars were going out.
  -- Arthur C Clarke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant