From 96d910c770b9443e204e183d3f3a8720c346a79c Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Tue, 3 Aug 2004 08:05:27 +0000 Subject: [PATCH] Call map_file() with its new args, including a suggested window size. --- checksum.c | 2 +- generator.c | 4 ++-- receiver.c | 3 ++- sender.c | 6 +++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/checksum.c b/checksum.c index 3db63da0..e3b8719a 100644 --- a/checksum.c +++ b/checksum.c @@ -102,7 +102,7 @@ void file_checksum(char *fname,char *sum,OFF_T size) if (fd == -1) return; - buf = map_file(fd, size, CSUM_CHUNK); + buf = map_file(fd, size, CSUM_CHUNK * 2048, 0); mdfour_begin(&m); diff --git a/generator.c b/generator.c index 8a73420d..04975b6c 100644 --- a/generator.c +++ b/generator.c @@ -154,7 +154,7 @@ static void sum_sizes_sqroot(struct sum_struct *sum, uint64 len) c >>= 1; } while (c >= 8); /* round to multiple of 8 */ blength = MAX(blength, BLOCK_SIZE); - blength = MIN(blength, MAX_MAP_SIZE); + blength = MIN(blength, MAX_BLOCK_SIZE); } if (protocol_version < 27) { @@ -209,7 +209,7 @@ static void generate_and_send_sums(int fd, OFF_T len, int f_out) sum_sizes_sqroot(&sum, len); if (len > 0) - mapbuf = map_file(fd, len, sum.blength); + mapbuf = map_file(fd, len, MAX_MAP_SIZE, sum.blength); else mapbuf = NULL; diff --git a/receiver.c b/receiver.c index a62bc061..9e40fcbf 100644 --- a/receiver.c +++ b/receiver.c @@ -222,7 +222,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r, read_sum_head(f_in, &sum); if (fd_r >= 0 && size_r > 0) { - mapbuf = map_file(fd_r, size_r, sum.blength); + OFF_T map_size = MAX(sum.blength * 2, 16*1024); + mapbuf = map_file(fd_r, size_r, map_size, sum.blength); if (verbose > 2) { rprintf(FINFO, "recv mapped %s of size %.0f\n", safe_fname(fname_r), (double)size_r); diff --git a/sender.c b/sender.c index c5dffc1c..1436eb6c 100644 --- a/sender.c +++ b/sender.c @@ -208,7 +208,11 @@ void send_files(struct file_list *flist, int f_out, int f_in) return; } - mbuf = st.st_size ? map_file(fd, st.st_size, s->blength) : NULL; + if (st.st_size) { + OFF_T map_size = MAX(s->blength * 3, MAX_MAP_SIZE); + mbuf = map_file(fd, st.st_size, map_size, s->blength); + } else + mbuf = NULL; if (verbose > 2) { rprintf(FINFO, "send_files mapped %s of size %.0f\n", -- 2.34.1