From 7f1c3e78a333b813cd97ac1d256a8bc55b32d4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20von=20Hoe=C3=9Flin?= Date: Tue, 30 Apr 2024 13:48:05 +0200 Subject: [PATCH 1/2] unattended resume input stream --- src/Io/CloseProtectionStream.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Io/CloseProtectionStream.php b/src/Io/CloseProtectionStream.php index 2e1ed6e4..91c38aaa 100644 --- a/src/Io/CloseProtectionStream.php +++ b/src/Io/CloseProtectionStream.php @@ -80,11 +80,7 @@ public function close() $this->input->removeListener('end', array($this, 'handleEnd')); $this->input->removeListener('close', array($this, 'close')); - // resume the stream to ensure we discard everything from incoming connection - if ($this->paused) { - $this->paused = false; - $this->input->resume(); - } + $this->close(); $this->emit('close'); $this->removeAllListeners(); From 2b03dc0e56a0b49ffb70da59800207bc3e342714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20von=20Hoe=C3=9Flin?= Date: Tue, 30 Apr 2024 13:48:05 +0200 Subject: [PATCH 2/2] Unnecessary resume input stream --- src/Io/CloseProtectionStream.php | 6 +----- tests/Io/CloseProtectionStreamTest.php | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Io/CloseProtectionStream.php b/src/Io/CloseProtectionStream.php index 2e1ed6e4..91c38aaa 100644 --- a/src/Io/CloseProtectionStream.php +++ b/src/Io/CloseProtectionStream.php @@ -80,11 +80,7 @@ public function close() $this->input->removeListener('end', array($this, 'handleEnd')); $this->input->removeListener('close', array($this, 'close')); - // resume the stream to ensure we discard everything from incoming connection - if ($this->paused) { - $this->paused = false; - $this->input->resume(); - } + $this->close(); $this->emit('close'); $this->removeAllListeners(); diff --git a/tests/Io/CloseProtectionStreamTest.php b/tests/Io/CloseProtectionStreamTest.php index 8490daff..80c0c719 100644 --- a/tests/Io/CloseProtectionStreamTest.php +++ b/tests/Io/CloseProtectionStreamTest.php @@ -48,7 +48,7 @@ public function testCloseResumesInputStreamIfItWasPreviouslyPaused() { $input = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock(); $input->expects($this->once())->method('pause'); - $input->expects($this->once())->method('resume'); + $input->expects($this->never())->method('resume'); $protection = new CloseProtectionStream($input); $protection->pause();