From: Volker Lendecke Date: Mon, 15 Dec 2008 11:06:00 +0000 (+0100) Subject: Prefer network writes over reads X-Git-Tag: samba-4.0.0alpha6~467^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fe7d5936aea2ab74bf63997212f509e4a3ccee4;p=thirdparty%2Fsamba.git Prefer network writes over reads If we really want to keep the pipe busy, we need to write everything we have as early as possible, giving the kernel the chance to get rid of the buffers quickly :-) --- diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c index fd2fe930f84..522d73fbd9e 100644 --- a/source3/libsmb/async_smb.c +++ b/source3/libsmb/async_smb.c @@ -955,6 +955,39 @@ static void cli_state_handler(struct event_context *event_ctx, DEBUG(11, ("cli_state_handler called with flags %d\n", flags)); + if (flags & EVENT_FD_WRITE) { + size_t to_send; + ssize_t sent; + + for (req = cli->outstanding_requests; req; req = req->next) { + to_send = smb_len(req->outbuf)+4; + if (to_send > req->sent) { + break; + } + } + + if (req == NULL) { + if (cli->fd_event != NULL) { + event_fd_set_not_writeable(cli->fd_event); + } + return; + } + + sent = sys_send(cli->fd, req->outbuf + req->sent, + to_send - req->sent, 0); + + if (sent < 0) { + status = map_nt_error_from_unix(errno); + goto sock_error; + } + + req->sent += sent; + + if (req->sent == to_send) { + return; + } + } + if (flags & EVENT_FD_READ) { int res, available; size_t old_size, new_size; @@ -1020,38 +1053,6 @@ static void cli_state_handler(struct event_context *event_ctx, } } - if (flags & EVENT_FD_WRITE) { - size_t to_send; - ssize_t sent; - - for (req = cli->outstanding_requests; req; req = req->next) { - to_send = smb_len(req->outbuf)+4; - if (to_send > req->sent) { - break; - } - } - - if (req == NULL) { - if (cli->fd_event != NULL) { - event_fd_set_not_writeable(cli->fd_event); - } - return; - } - - sent = sys_send(cli->fd, req->outbuf + req->sent, - to_send - req->sent, 0); - - if (sent < 0) { - status = map_nt_error_from_unix(errno); - goto sock_error; - } - - req->sent += sent; - - if (req->sent == to_send) { - return; - } - } return; sock_error: