From: Matt S Trout Date: Fri, 11 Nov 2011 08:30:03 +0000 (+0000) Subject: add comments to clarify the initial handshake X-Git-Tag: v0.001001~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9df46eb8e416e9e16d5532b305c787e12f1879de;p=scpubgit%2FTak.git add comments to clarify the initial handshake --- diff --git a/lib/Tak/ConnectorService.pm b/lib/Tak/ConnectorService.pm index a3a3caa..7e1d4b1 100644 --- a/lib/Tak/ConnectorService.pm +++ b/lib/Tak/ConnectorService.pm @@ -19,9 +19,12 @@ sub handle_create { my $log_level = $args{log_level}||'info'; my ($kid_in, $kid_out, $kid_pid) = $self->_open($on, $log_level); $kid_in->print(io('maint/mk-fat |')->all, "__END__\n"); + # Need to get a handshake to indicate STDIOSetup has finished + # messing around with file descriptors, otherwise we can severely + # confuse things by sending before the dup. my $up = <$kid_out>; die [ failure => "Garbled response from child: $up" ] - unless $up eq "UP\n"; + unless $up eq "Ssyshere\n"; my $connection = Tak::ConnectionService->new( read_fh => $kid_out, write_fh => $kid_in, listening_service => Tak::Router->new diff --git a/lib/Tak/STDIOSetup.pm b/lib/Tak/STDIOSetup.pm index 1a9fc9e..d090f06 100644 --- a/lib/Tak/STDIOSetup.pm +++ b/lib/Tak/STDIOSetup.pm @@ -38,7 +38,9 @@ sub run { $0 = 'tak-stdio-node'; } log_debug { "Node starting" }; - print $stdout "UP\n"; + # Tell the other end that we've finished messing around with file + # descriptors and that it's therefore safe to start sending requests. + print $stdout "Ssyshere\n"; Tak->loop_until($done); }