Hi, All ! Is ot possible to use threads and LWP modules together ?
I tried to run simple programm: =================================================== #!/usr/bin/perl5 use LWP::UserAgent; use threads; my $ua = LWP::UserAgent->new; $req = HTTP::Request->new(GET => 'http://www.liniya.ru/robots.txt'); $res = $ua->request($req); print $res->as_string; $thr = threads->new(\&sub1, "Param 1"); $thr->join; sub sub1 { my (@InboundParameters) = @_; print "In the thread\n"; print "got parameters >", join("<>", @InboundParameters), "<\n"; }; =================================================== Result is unexpected: =================================================== HTTP/1.1 200 OK Connection: close Date: Wed, 29 Jan 2003 09:17:45 GMT Server: Apache/1.3.27 (Unix) PHP/4.1.2 mod_ssl/2.8.12 OpenSSL/0.9.6e Content-Type: text/html; charset=windows-1251 Client-Date: Wed, 29 Jan 2003 09:17:45 GMT Client-Peer: 195.34.31.254:80 Client-Response-Num: 1 Client-Transfer-Encoding: chunked User-Agent: * Disallow: /Cat/E/ Disallow: /Domen/ Bizarre SvTYPE [32] at ./ctest2 line 9. Segmentation fault (core dumped) =================================================== But when I comment lines $res = $ua->request($req); print $res->as_string; I got expected result: =================================================== In the thread got parameters >Param 1< =================================================== My system: FreeBSD 4.7-STABLE #1: Sun Jan 12 12:26:39 MSK 2003 Result of /usr/bin/perl5 -V =================================================== Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Platform: osname=freebsd, osvers=4.7-stable, archname=i386-freebsd-thread-multi uname='freebsd gw.lini-a.ru 4.7-stable freebsd 4.7-stable #1: sun jan 12 12:26:39 msk 2003 [EMAIL PROTECTED]:sourceusrobjsourceusrsrcsysgw i386 ' config_args='-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='cc', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/in clude', optimize='-O', cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/ local/include' ccversion='', gccversion='2.95.4 20020320 [FreeBSD]', 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='cc', ldflags ='-pthread -Wl,-E -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lgdbm -lm -lc_r -lcrypt -lutil perllibs=-lm -lc_r -lcrypt -lutil libc=, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-DPIC -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 freebsd Compiled at Jan 28 2003 18:38:33 @INC: /usr/local/lib/perl5/5.8.0/i386-freebsd-thread-multi /usr/local/lib/perl5/5.8.0 /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd-thread-multi /usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl . ===================================================
