This commit is contained in:
Alex Young
2014-02-27 16:18:17 +00:00
2 changed files with 8 additions and 1 deletions

View File

@@ -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 ); 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 ) { if ( xfer->written < hdr_size ) {
data_loc = ( (char*) &xfer->hdr.req_raw ) + ctrl->xfer.written; data_loc = ( (char*) &xfer->hdr.req_raw ) + ctrl->xfer.written;
to_write = hdr_size - 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. // All bytes written, so now we need to read the NBD reply back.
if ( ctrl->xfer.written == ctrl->xfer.len + hdr_size ) { 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_start( loop, &ctrl->read_watcher );
ev_io_stop( loop, &ctrl->write_watcher ); ev_io_stop( loop, &ctrl->write_watcher );
} }

View File

@@ -138,7 +138,7 @@ module FlexNBD
end 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 client_sock = nil
begin begin