summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-12-15 12:06:00 +0100
committerVolker Lendecke <vl@samba.org>2008-12-19 13:46:52 +0100
commit2fe7d5936aea2ab74bf63997212f509e4a3ccee4 (patch)
tree3ee194dd86471083be81b12ea56900e45d80ee28 /source3
parent3c6d070595dee97151afa6eba6cef3ebe6ee3cfb (diff)
downloadsamba-2fe7d5936aea2ab74bf63997212f509e4a3ccee4.tar.gz
samba-2fe7d5936aea2ab74bf63997212f509e4a3ccee4.tar.bz2
samba-2fe7d5936aea2ab74bf63997212f509e4a3ccee4.zip
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 :-)
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/async_smb.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index fd2fe930f8..522d73fbd9 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: