perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard F. Rebel" <rre...@whenu.com>
Subject [mp2] Problem reading from sockets under high volume.
Date Thu, 26 Jun 2003 18:51:33 GMT
-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:

To generate a page I am doing a very simple http get to a remote server
for some XML data that I later process.  I have written a module to do
this that contains the subroutine I cobbled together to do this.  The
module works correctly but under heavy load I get hundreds of:

ERROR Interrupted system call

This does not occur during with few clients, nor when I make it into a
small program and run it from the command line.  From the man page of
select() EINTR is supposed to be caused by an uncaught signal.  How can
I tell what it is?  There are no signals that I know of being generated,
nor any reason for them.  I think this is a bug in either mod_perl,
perl, or Apache but I haven't a cloo as to what to do to narrow it down.

Thanks for your kind attention.

Richard

##########
use strict;
use Symbol;
use Fcntl	qw(:DEFAULT);
use Socket;

use Time::HiRes;

sub simple {
	my $host = shift || return undef;
	my $port = shift || return undef;
	my $mesg = shift || return undef;
	my $timeout = shift || 60;
	my $t0 = Time::HiRes::time(); my $ti;
	my $proto = getprotobyname('tcp'); 
	my $iaddr = inet_aton($host) || return undef;
	my $paddr = sockaddr_in($port, $iaddr);
	my $s = Symbol::gensym;
	socket($s, PF_INET, SOCK_STREAM, $proto) || return undef;
	connect($s, $paddr) || return undef;
	my $fd = fileno($s);
	my $t; my $b; my $res; my $nf; my $tl;
	my $buf = "\000" x 8120; ## BUFSIZ
	my $l = length($mesg);
	my $rin = 0 ; my $win = 0 , my $ein = 0; my $rout = 0; my $wout = 0; my
$eout = 0;
	vec($rin, $fd, 1) = 1;
	vec($win, $fd, 1) = 1;
	$ein = $rin | $win;
	my $i;
	$t = 0; $b = 0;
	while (($nf, $tl) = select(undef, $wout=$win, $eout=$ein, 2)) {
		$i++;
		$ti = Time::HiRes::time() - $t0;
		if ($ti > $timeout) {
			print STDERR "Timed out writing ($ti) $!\n";
			shutdown($s, 2);
			return undef;
		}
		if (vec($wout, $fd, 1) == 1) {
			$b = syswrite($s, $mesg, $l - $b, $b);
			$t = $t + $b;
			last if $t = $l;
		}
		if (vec($eout, $fd, 1) == 1) {
			print STDERR "Got an error while writing: $!\n";
			shutdown($s, 2);
			return undef;
		}
	}
	$t = 0; $l = 0; $b = 0;
	while (($nf, $tl) = select($rout=$rin, undef, $eout=$ein, 2)) {
		$i++;
		$ti = Time::HiRes::time() - $t0;
		if ($!) { 
			print STDERR "ERROR $!\n";
		}
		if ($ti > $timeout) {
			print STDERR "Timed out reading ($ti) $!\n";
			shutdown($s, 2);
			return undef;
		}
		if (vec($rout, $fd, 1) == 1) {
			$b = sysread($s, $buf, 8192);
			$t = $t + $b;
			last if $b == 0;
			$res .= $buf;
		}
		if (vec($eout, $fd, 1) == 1) {
			print STDERR "Got an error while reading: $!\n";
			shutdown($s, 2);
			return undef;
		}
	}
	shutdown($s, 2);
	return $res;
}


2. Used Components and their Configuration:

*** using
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/Apache2/Apache/BuildConfig.pm
*** Makefile.PL options:
  MP_APXS         => /usr/sbin/apxs2
  MP_AP_PREFIX    => /usr
  MP_DEBUG        => 1
  MP_GENERATE_XS  => 1
  MP_INST_APACHE2 => 1
  MP_LIBNAME      => mod_perl
  MP_TRACE        => 1
  MP_USE_DSO      => 1


*** /usr/sbin/httpd -V
Server version: Apache-AdvancedExtranetServer/2.0.45
Server built:   Jun 26 2003 10:49:49
Server's Module Magic Number: 20020903:0
Architecture:   32-bit
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/worker"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D HTTPD_ROOT="/etc/httpd/2.0"
 -D SUEXEC_BIN="/usr/sbin/apache2-suexec"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd2.conf"


*** /usr/bin/perl -V
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.20-2mdkenterprise,
archname=i386-linux-thread-multi
    uname='linux no.mandrakesoft.com 2.4.20-2mdkenterprise #1 smp mon
dec 9 14:28:32 cet 2002 i686 unknown unknown gnulinux '
    config_args='-des -Darchname=i386-linux -Dcc=gcc -Doptimize=-O2
-fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpro -Dprefix=/usr
-Dvendorprefix=/usr -Dsiteprefix=/usr -Dman3ext=3pm -Dcf_by=MandrakeSoft
-Dmyhostname=localhost -Dperladmin=root@localhost -Dd_dosuid -Ud_csh
-Duseshrplib -Dusethreads'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=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 ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2 -fomit-frame-pointer -pipe -march=i586
-mcpu=pentiumpro',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-I/usr/include/gdbm'
    ccversion='', gccversion='3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk)',
gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldl -lm -lpthread -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
    libc=/lib/libc-2.3.1.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.3.1'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic
-Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
  Built under linux
  Compiled at Mar  6 2003 22:13:55
  %ENV:
    PERL_LWP_USE_HTTP_10="1"
  @INC:
    /usr/lib/perl5/5.8.0/i386-linux-thread-multi
    /usr/lib/perl5/5.8.0
    /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.0
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.0
    /usr/lib/perl5/vendor_perl
    .


3. This is the core dump trace: (if you get a core dump):

  [CORE TRACE COMES HERE]

This report was generated by -e on Thu Jun 26 18:41:08 2003 GMT.

-------------8<---------- End Bug Report --------------8<----------

Note: Complete the rest of the details and post this bug report to
dev <at> perl.apache.org. To subscribe to the list send an empty
email to dev-subscribe@perl.apache.org.

-- 
Richard F. Rebel
rrebel@whenu.com
t. 212.239.0000


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message