-
-
Save anonymous/79ea7587c76d368072c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/t/mojo/ioloop.t b/t/mojo/ioloop.t | |
index 58a1f76..c258936 100644 | |
--- a/t/mojo/ioloop.t | |
+++ b/t/mojo/ioloop.t | |
@@ -198,6 +198,32 @@ $id = Mojo::IOLoop->client( | |
$delay->wait; | |
is $removed, 1, 'connection has been removed'; | |
+# Interrupted writes | |
+$buffer = ''; | |
+$delay = Mojo::IOLoop->delay; | |
+$end = $delay->begin; | |
+$id = Mojo::IOLoop->server( | |
+ (address => '127.0.0.1') => sub { | |
+ my ($loop, $stream) = @_; | |
+ $stream->on(close => $end); | |
+ $stream->on(read => sub { $buffer .= pop }); | |
+ my $cb; | |
+ $cb = sub { shift->write('ping' => $cb) }; | |
+ $stream->$cb; | |
+ } | |
+); | |
+$port = Mojo::IOLoop->acceptor($id)->port; | |
+$id = Mojo::IOLoop->client( | |
+ (port => $port) => sub { | |
+ my ($loop, $err, $stream) = @_; | |
+ $stream->stop; | |
+ shutdown $stream->handle, 0; | |
+ $stream->write('pong')->close_gracefully; | |
+ } | |
+); | |
+$delay->wait; | |
+is $buffer, 'pong', 'right result'; | |
+ | |
# Stream throttling | |
my ($client, $server, $client_after, $server_before, $server_after); | |
$id = Mojo::IOLoop->server( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment