From dbe7053bf3256332296bec0c1a9cd8e229cfdb17 Mon Sep 17 00:00:00 2001 From: nick Date: Thu, 27 Feb 2014 14:32:26 +0000 Subject: [PATCH 1/2] Avoid some false positives --- tests/acceptance/flexnbd/fake_dest.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/flexnbd/fake_dest.rb b/tests/acceptance/flexnbd/fake_dest.rb index 25df522..c96dc2b 100644 --- a/tests/acceptance/flexnbd/fake_dest.rb +++ b/tests/acceptance/flexnbd/fake_dest.rb @@ -138,7 +138,7 @@ module FlexNBD end - def accept( err_msg = "Timed out waiting for a connection", timeout = 2) + def accept( err_msg = "Timed out waiting for a connection", timeout = 5) client_sock = nil begin From 705164ae3bc345ddf7699c16c41bfb5c8b92c354 Mon Sep 17 00:00:00 2001 From: nick Date: Thu, 27 Feb 2014 14:32:54 +0000 Subject: [PATCH 2/2] Cork/uncork in mirror - socket_connect already sets nodelay --- src/common/mirror.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/mirror.c b/src/common/mirror.c index 646e4c0..becfa76 100644 --- a/src/common/mirror.c +++ b/src/common/mirror.c @@ -462,6 +462,12 @@ static void mirror_write_cb( struct ev_loop *loop, ev_io *w, int revents ) debug( "Mirror write callback invoked with events %d. fd: %i", revents, ctrl->mirror->client ); + /* FIXME: We can end up corking multiple times in unusual circumstances; this + * is annoying, but harmless */ + if ( xfer->written == 0 ) { + sock_set_tcp_cork( ctrl->mirror->client, 1 ); + } + if ( xfer->written < hdr_size ) { data_loc = ( (char*) &xfer->hdr.req_raw ) + ctrl->xfer.written; to_write = hdr_size - xfer->written; @@ -489,6 +495,7 @@ static void mirror_write_cb( struct ev_loop *loop, ev_io *w, int revents ) // All bytes written, so now we need to read the NBD reply back. if ( ctrl->xfer.written == ctrl->xfer.len + hdr_size ) { + sock_set_tcp_cork( ctrl->mirror->client, 0 ) ; ev_io_start( loop, &ctrl->read_watcher ); ev_io_stop( loop, &ctrl->write_watcher ); }