Closed p5pRT closed 20 years ago
What's the \
Bugs remaining
1: I've no idea what the missing text after "We'll" should be:
a time. Multithreaded servers are covered in Chapter 6 of the Camel.
Here's the code. We'll
#!/usr/bin/perl -w
2: The example that follows uses Net::hostent. It's not working becuse Net::hostent in bleadperl is shagged.
3: Net::hostent doesn't have a regression test to detected that it's shagged.
Hopefully I'll get a chance to fix 2 and 3 tomorrow.
Nicholas Clark
*** pod/perlipc.pod.orig Tue Nov 7 00:12:07 2000
--- pod/perlipc.pod Tue Nov 28 10:58:41 2000
***************
*** 660\,673 ****
BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
use Socket;
use Carp;
! $EOL = "\015\012";
sub logmsg { print "$0 $$: @_ at "\, scalar localtime\, "\n" }
my $port = shift || 2345;
my $proto = getprotobyname('tcp');
! ($port) = $port =~ /^(\d+)$/ || die "invalid port";
socket(Server\, PF_INET\, SOCK_STREAM\, $proto) || die "socket: $!";
setsockopt(Server\, SOL_SOCKET\, SO_REUSEADDR\,
--- 660\,673 ----
BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
use Socket;
use Carp;
! my $EOL = "\015\012";
sub logmsg { print "$0 $$: @_ at "\, scalar localtime\, "\n" }
my $port = shift || 2345;
my $proto = getprotobyname('tcp');
! ($port) = $port =~ /^(\d+)$/ or die "invalid port";
socket(Server\, PF_INET\, SOCK_STREAM\, $proto) || die "socket: $!";
setsockopt(Server\, SOL_SOCKET\, SO_REUSEADDR\,
***************
*** 703\,709 ****
BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
use Socket;
use Carp;
! $EOL = "\015\012";
sub spawn; # forward declaration
sub logmsg { print "$0 $$: @_ at "\, scalar localtime\, "\n" }
--- 703\,709 ----
BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
use Socket;
use Carp;
! my $EOL = "\015\012";
sub spawn; # forward declaration
sub logmsg { print "$0 $$: @_ at "\, scalar localtime\, "\n" }
***************
*** 711\,717 ****
my $port = shift || 2345;
my $proto = getprotobyname('tcp');
! ($port) = $port =~ /^(\d+)$/ || die "invalid port";
socket(Server\, PF_INET\, SOCK_STREAM\, $proto) || die "socket: $!";
setsockopt(Server\, SOL_SOCKET\, SO_REUSEADDR\,
--- 711\,717 ----
my $port = shift || 2345;
my $proto = getprotobyname('tcp');
! ($port) = $port =~ /^(\d+)$/ or die "invalid port";
socket(Server\, PF_INET\, SOCK_STREAM\, $proto) || die "socket: $!";
setsockopt(Server\, SOL_SOCKET\, SO_REUSEADDR\,
***************
*** 865\,870 ****
--- 865\,871 ----
use Carp;
BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
+ sub spawn; # forward declaration
sub logmsg { print "$0 $$: @_ at "\, scalar localtime\, "\n" }
my $NAME = '/tmp/catsock';
***************
*** 899\,904 ****
--- 900\,928 ----
print "Hello there\, it's now "\, scalar localtime\, "\n";
exec '/usr/games/fortune' or die "can't exec fortune: $!";
};
+ }
+
+ sub spawn {
+ my $coderef = shift;
+
+ unless (@_ == 0 && $coderef && ref($coderef) eq 'CODE') {
+ confess "usage: spawn CODEREF";
+ }
+
+ my $pid;
+ if (!defined($pid = fork)) {
+ logmsg "cannot fork: $!";
+ return;
+ } elsif ($pid) {
+ logmsg "begat $pid";
+ return; # I'm the parent
+ }
+ # else I'm the child -- go spawn
+
+ open(STDIN\, "\<&Client") || die "can't dup client to stdin";
+ open(STDOUT\, ">&Client") || die "can't dup client to stdout";
+ ## open(STDERR\, ">&STDOUT") || die "can't dup stdout to stderr";
+ exit &$coderef();
}
As you see\, it's remarkably similar to the Internet domain TCP server\, so
Lightning flashed\, thunder crashed and Nicholas Clark \nick@​babyhippo\.co\.uk wh ispered: | Bugs remaining |
---|---|
1: I've no idea what the missing text after "We'll" should be: | |
a time. Multithreaded servers are covered in Chapter 6 of | |
the Camel. | |
Here's the code. We'll | |
#!/usr/bin/perl -w |
Looks like the "We'll" can just be removed.
While someone is looking at this\, the first paragraph in this section\, which starts "Once the generic server socket has been created..." needs work as well. Specifically\, this sentence which seems to be missing something:
"The server blocks in the C\
-spp
On Tue\, Nov 28\, 2000 at 11:16:57AM +0000\, Nicholas Clark wrote:
This is a bug report for perl from nick@talking.bollo.cx\, generated with the help of perlbug 1.33 running under perl v5.7.0.
----------------------------------------------------------------- [Please enter your report here]
What's the \
point of example code if it's buggy? Not only do some of the perlipc code fail to compile in the first place\, but even when you fix those bugs two have subtle precedence bugs w.r.t. "or" versus "||" and scalar/list context. Bugs remaining
1: I've no idea what the missing text after "We'll" should be:
a time\. Multithreaded servers are covered in Chapter 6 of the Camel\. Here's the code\. We'll \#\!/usr/bin/perl \-w
2: The example that follows uses Net::hostent. It's not working becuse Net::hostent in bleadperl is shagged.
3: Net::hostent doesn't have a regression test to detected that it's shagged.
Writing a portable test that still tests anything useful for the gethost* is tough. Remember that the contents or the existence of the /etc/hosts file might be largely irrelevant to to results of the gethost* calls.
On Tue\, Nov 28\, 2000 at 09:43:40AM -0600\, Jarkko Hietaniemi wrote:
On Tue\, Nov 28\, 2000 at 11:16:57AM +0000\, Nicholas Clark wrote:
3: Net::hostent doesn't have a regression test to detected that it's shagged.
Writing a portable test that still tests anything useful for the gethost* is tough. Remember that the contents or the existence of the /etc/hosts file might be largely irrelevant to to results of the gethost* calls.
$ cat t/lib/net_hostent.t #!./perl -w BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use Net::hostent; $loaded = 1; print "ok 1\n";
It's better than nothing? (cribbed from h2xs)
Nicholas Clark
On Tue\, Nov 28\, 2000 at 03:53:56PM +0000\, Nicholas Clark wrote:
On Tue\, Nov 28\, 2000 at 09:43:40AM -0600\, Jarkko Hietaniemi wrote:
On Tue\, Nov 28\, 2000 at 11:16:57AM +0000\, Nicholas Clark wrote:
3: Net::hostent doesn't have a regression test to detected that it's shagged.
Writing a portable test that still tests anything useful for the gethost* is tough. Remember that the contents or the existence of the /etc/hosts file might be largely irrelevant to to results of the gethost* calls.
$ cat t/lib/net_hostent.t #!./perl -w BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use Net::hostent; $loaded = 1; print "ok 1\n";
It's better than nothing? (cribbed from h2xs)
Well\, it's better than nothing\, but is that enough for your purposes?
On Tue\, Nov 28\, 2000 at 10:01:42AM -0600\, Jarkko Hietaniemi wrote:
Well\, it's better than nothing\, but is that enough for your purposes?
I didn't think I had a "purpose" in mind. I just found it rather scary that we can "ship" modules in the standard library that don't even compile >>without anyone realising\<\<
I guess it's time to run the regression tests and then find lib -type f | xargs ls -ltu to find all that weren't accessed and add placeholder tests to at least verify that they still load.
Nicholas Clark
On Tue\, Nov 28\, 2000 at 11:16:57AM +0000\, Nicholas Clark wrote:
1: I've no idea what the missing text after "We'll" should be:
a time\. Multithreaded servers are covered in Chapter 6 of the Camel\.
Also\, edition specific material detected; is the above sentence still true for PP3?
"NC" == Nicholas Clark \nick@​ccl4\.org writes:
NC> On Tue\, Nov 28\, 2000 at 09:43:40AM -0600\, Jarkko Hietaniemi wrote:
On Tue\, Nov 28\, 2000 at 11:16:57AM +0000\, Nicholas Clark wrote:
3: Net::hostent doesn't have a regression test to detected that it's shagged.
Writing a portable test that still tests anything useful for the gethost* is tough. Remember that the contents or the existence of the /etc/hosts file might be largely irrelevant to to results of the gethost* calls.
NC> $ cat t/lib/net_hostent.t #!./perl -w BEGIN { $| = 1; print NC> "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use NC> Net::hostent; $loaded = 1; print "ok 1\n";
NC> It's better than nothing? (cribbed from h2xs)
What about this one? I added some really really simple functionality tests\, just to go a little further than simple compilation. Tested on Win32 and Linux.
#!./perl -w BEGIN { $| = 1; print "1..5\n"; } END {print "not ok 1\n" unless $loaded;} use Net::hostent; $loaded = 1; print "ok 1\n";
# test basic resolution of localhost \<-> 127.0.0.1 use Socket;
my $h = gethost('localhost'); my $i = gethostbyaddr(inet_aton("127.0.0.1"));
print "not " if inet_ntoa($h->addr) ne "127.0.0.1"; print "ok 2\n";
print "not " if inet_ntoa($i->addr) ne "127.0.0.1"; print "ok 3\n";
# need to skip the name comparisons on Win32 because windows will # return the name of the machine instead of "localhost" when resolving # 127.0.0.1 or even "localhost"
if ($^O eq 'MSWin32') { print "ok $_ # skipped on win32\n" for (4\,5); } else { print "not " if $h->name ne "localhost"; print "ok 4\n";
print "not " if $i->name ne "localhost"; print "ok 5\n"; }
NC> "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use NC> Net::hostent; $loaded = 1; print "ok 1\n";
NC> It's better than nothing? (cribbed from h2xs)
What about this one? I added some really really simple functionality tests\, just to go a little further than simple compilation. Tested on Win32 and Linux.
Looks good.
On Tue\, Nov 28\, 2000 at 04:17:31PM +0000\, Nicholas Clark wrote:
On Tue\, Nov 28\, 2000 at 10:01:42AM -0600\, Jarkko Hietaniemi wrote:
Well\, it's better than nothing\, but is that enough for your purposes?
I didn't think I had a "purpose" in mind. I just found it rather scary that we can "ship" modules in the standard library that don't even compile >>without anyone realising\<\<
I can't argue with that...
I guess it's time to run the regression tests and then find lib -type f | xargs ls -ltu to find all that weren't accessed and add placeholder tests to at least verify that they still load.
Nicholas Clark
On Sun\, Dec 03\, 2000 at 12:21:03PM +0000\, Simon Cozens wrote:
On Tue\, Nov 28\, 2000 at 11:16:57AM +0000\, Nicholas Clark wrote:
1: I've no idea what the missing text after "We'll" should be:
a time\. Multithreaded servers are covered in Chapter 6 of the Camel\.
Also\, edition specific material detected; is the above sentence still true for PP3?
Chapter 6 is "subroutines" so that's a no. I can't find multithreaded servers in the index\, or that sentence in a quick skim of chapter 16 "Interprocess Communication" so I don't know where that information is. I also don't have a PP2 here\, so I can't use that as a guide to where to start. Hence no correction patch.
Nicholas Clark
Migrated from rt.perl.org#4792 (status was 'resolved')
Searchable as RT4792$