On Tue, May 19, 2015 at 09:22:40AM +0000, Michael Deegan wrote:
> It does not...because the socket continues to be at EOF. :P
> 
> Doing "last LOOP" instead does work, but makes me wonder uncomfortably 
> whether this would result (under certain currently unspecified and 
> unreproducible circumstances) in the tail end of data from the other socket 
> to be forgotten, though I'm also mindful of the possibility of it being safe 
> to give up as soon as either side becomes unreadable.
> 
> I feel that doing "$s->remove($_)" instead (a la the attached patch against 
> 1.7.10) would give the other socket a chance to finish more cleanly.

Michael,

I have been thinking about this, in particular this thread:
http://www.perlmonks.org/bare/?node_id=167036

shutdown(1) seems to be the best we can do to pass the EOF on. How does this
patch work for you?

Mark

diff --git a/apt-cacher b/apt-cacher
index 1317c25..069bad0 100755
--- a/apt-cacher
+++ b/apt-cacher
@@ -457,6 +457,13 @@ sub ssl_proxy {
                if(defined(my $num=sysread($_, my $buf,65536))) {
                    local $SIG{PIPE} = sub {$cfg->{debug} && debug_message('Got 
SIGPIPE whilst proxying')}; # Catch disconnects/write failure
                    my $writeto = (fileno($_)==fileno($ssl)?$con:$ssl);
+                   unless ($num) { # EOF
+                       my $h=$_->peerhost;
+                        $cfg->{debug} && debug_message("Got EOF from $h");
+                       $writeto->shutdown(1);
+                        $s->remove($_);
+                       last;
+                   }
                    last LOOP if !defined(syswrite($writeto,$buf,$num));
                    $count += $num;
                }


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to