x86和powerpc上的perl版本都是5.8.8。
有谁porting过perl,或者遇到过类似问题?为什么select无法阻塞?
服务器运行在一台x86上。分别在另一台X86和powerpc上运行客户端,perl版本都是5.8.8。
X86上客户端返回
**********
UDP:SUCCESS
powerpc上客户端返回
**********
UDP:FAILURE
我甚至运行过LTP的测试用例syscalls,system select call应该没问题。
~ # ls /usr/local/ltp/runtest/
commands ipc modules sched tcp_cmds
crashme ipv6 multicast sctp tcp_cmds_noexpect
dio ipv6_noexpect nfs select-test timers
fs lvm.part1 pipes stress.part1
fsx lvm.part2 pty stress.part2
hyperthreading math quickhit stress.part3
io mm rpc syscalls
~ # cd /usr/local/ltp/
~ # /usr/local/ltp # ./runltp -p -l ~/syscall.log -f syscalls
Here is part of the test log of system calls test case.
Test Start Time: Wed Apr 2 12:23:19 2025
-----------------------------------------
Testcase Result Exit Value
-------- ------ ----------
abort01 PASS 0
accept01 PASS 0
...
select01 PASS 0
select02 PASS 0
select03 PASS 0
...
writev01 PASS 0
writev02 PASS 0
writev03 PASS 0
writev04 PASS 0
writev05 PASS 0
-----------------------------------------------
Total Tests: 705
Total Failures: 5
Kernel Version: 2.6.27.6
Machine Architecture: ppc
Hostname: mpc8572ds
-----------------------------------
以下是测试脚本:
服务器: udps.pl
#!/usr/bin/perl -w
use IO::Socket;
# alarm(60);
$port=3000;
$server = IO::Socket::INET -> new(LocalPort=>$port,Proto=>"udp")
or die "udpserver error\n";
$count =0;
while(1)
{
print "udpserver...waiting\n";
$h = $server -> recv($msg,3);
$count ++;
print "Received the message $count times: \r\n";
$server -> send($msg);
print $msg . "\r\n";
}
客户端: udpclient.pl
#!/usr/bin/perl -w
use Socket;
$server_ip=$ARGV[0];
$port=3000;
$mess="hi";
$server = socket(SOCKET,PF_INET,SOCK_DGRAM,getprotobyname("udp"))
or die "udpclient error\n";
$ipaddr=inet_aton($server_ip);
$portaddr=sockaddr_in($port,$ipaddr);
send(SOCKET,$mess,0,$portaddr)or die "udp send error:$!\n"
or die "can't send client";
sub w_key {
my($rin) = $_;
$rout = "";
vec($rin, fileno(SOCKET), 1) = 1;
return $nfd = select($rout=$rin,undef,undef,2);
}
$rin="";
vec($rin,fileno(SOCKET),1)=1;
$count=1;
while($count && w_key($rin)) {
$src=recv(SOCKET,$message,3,0) or die "udp client recv error:$!\n";
$count--; }
if($message eq "hi") {
print "**********\n";
print "UDP:SUCCESS\n";
}
else {
print "**********\n";
print "UDP:FAILURE\n";
}
exit();
用调试器,调试信息如下
~ # perl -d udpclient.pl 10.193.20.89
Loading DB routines from perl5db.pl version 1.28 Editor support
available.
Enter h or `h h' for help, or `man perldebug' for more help.
Name "main::src" used only once: possible typo at udpclient.pl line
35.
at udpclient.pl line 35
Name "main::server" used only once: possible typo at udpclient.pl line
6.
at udpclient.pl line 6
main::(udpclient.pl:3): $server_ip=$ARGV[0];
DB<1> s
main::(udpclient.pl:4): $port=3000;
DB<1>
main::(udpclient.pl:5): $mess="hi";
DB<1>
main::(udpclient.pl:6): $server = socket
(SOCKET,PF_INET,SOCK_DGRAM,getprotobyname("udp"))
main::(udpclient.pl:7): or die "udpclient error\n";
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:388):
388: my($constname);
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:389):
389: ($constname = $AUTOLOAD) =~ s/.*:://;
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:390):
390: croak "&Socket::constant not defined" if $constname eq
'constant';
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:391):
391: my ($error, $val) = constant($constname);
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:392):
392: if ($error) {
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:395):
395: *$AUTOLOAD = sub { $val };
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:396):
396: goto &$AUTOLOAD;
DB<1>
Socket::__ANON__[/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:395](/usr/
lib/perl5/5.8.8/ppc-linux/Socket.pm:395):
395: *$AUTOLOAD = sub { $val };
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:388):
388: my($constname);
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:389):
389: ($constname = $AUTOLOAD) =~ s/.*:://;
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:390):
390: croak "&Socket::constant not defined" if $constname eq
'constant';
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:391):
391: my ($error, $val) = constant($constname);
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:392):
392: if ($error) {
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:395):
395: *$AUTOLOAD = sub { $val };
DB<1>
Socket::AUTOLOAD(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:396):
396: goto &$AUTOLOAD;
DB<1>
Socket::__ANON__[/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:395](/usr/
lib/perl5/5.8.8/ppc-linux/Socket.pm:395):
395: *$AUTOLOAD = sub { $val };
DB<1>
main::(udpclient.pl:9): $ipaddr=inet_aton($server_ip);
DB<1>
main::(udpclient.pl:10): $portaddr=sockaddr_in($port,$ipaddr);
DB<1>
Socket::sockaddr_in(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:363):
363: if (@_ == 6 && !wantarray) { # perl5.001m compat; use this &&
die
DB<1>
Socket::sockaddr_in(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:372):
372: croak "usage: sin_sv = sockaddr_in(port,iaddr))" unless @_
== 2;
DB<1>
Socket::sockaddr_in(/usr/lib/perl5/5.8.8/ppc-linux/Socket.pm:373):
373: pack_sockaddr_in(@_);
DB<1>
main::(udpclient.pl:11): send(SOCKET,$mess,0,$portaddr)or die "udp
send error:$!\n"
main::(udpclient.pl:12): or die "can't send client";
DB<1>
main::(udpclient.pl:31): $rin="";
DB<1>
main::(udpclient.pl:32): vec($rin,fileno(SOCKET),1)=1;
DB<1>
main::(udpclient.pl:33): $count=1;
DB<1>
main::(udpclient.pl:34): while($count && w_key($rin)) {
DB<1>
main::w_key(udpclient.pl:15): my($rin) = $_;
DB<1>
main::w_key(udpclient.pl:16): vec($rin, fileno(SOCKET), 1) = 1;
DB<1>
Use of uninitialized value in vec at udpclient.pl line 16.
at udpclient.pl line 16
main::w_key('@') called at udpclient.pl line 34 Use of
uninitialized value in scalar assignment at udpclient.pl line 16.
at udpclient.pl line 16
main::w_key('@') called at udpclient.pl line 34
main::w_key(udpclient.pl:17): $rout = $rin;
DB<1>
main::w_key(udpclient.pl:18): $nfd = select($rout,undef,undef,2);
DB<1> x $rin
0 '@'
DB<2> x $rout
0 '@'
DB<3> s
main::w_key(udpclient.pl:19): if (vec($rout,fileno(SOCKET) ,1) ==
1 )
main::w_key(udpclient.pl:20): {
DB<3> x $rin
0 '@'
DB<4> x $rout
0 "\c@"
DB<5> s
main::w_key(udpclient.pl:25): print "There is no data waiting to
be read on SOCKET";
DB<5> s
main::w_key(udpclient.pl:27): return $nfd;
DB<5> There is no data waiting to be read on SOCKET
main::(udpclient.pl:38): if($message eq "hi") {
DB<5> x $nfd
0 0
DB<6> s
Use of uninitialized value in string eq at udpclient.pl line 38.
at udpclient.pl line 38
main::(udpclient.pl:43): print "**********\n";
DB<6> s
**********
main::(udpclient.pl:44): print "UDP:FAILURE\n";
DB<6> s
UDP:FAILURE
main::(udpclient.pl:46): exit();
DB<6> s
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<6> q
~ #
--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina Mongers 讨论组"论坛。
要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---
没有评论:
发表评论