]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
A few more compression tweaks.
authorWayne Davison <wayne@opencoder.net>
Mon, 25 May 2020 01:08:09 +0000 (18:08 -0700)
committerWayne Davison <wayne@opencoder.net>
Mon, 25 May 2020 01:43:03 +0000 (18:43 -0700)
compat.c
configure.ac
flist.c
options.c
rsync.h
token.c

index 3a5ad46d3bf4b95af08fdad4e8f5221b2e310efc..20dc85fd9c429a80f6eb299cf4f190b861099a2a 100644 (file)
--- a/compat.c
+++ b/compat.c
@@ -87,10 +87,6 @@ int filesfrom_convert = 0;
 
 #define MAX_NSTR_STRLEN 256
 
-#define CPRES_NONE 0
-#define CPRES_ZLIB 1
-#define CPRES_ZLIBX 2
-
 struct name_num_obj valid_compressions = {
        "compress", NULL, NULL, 0, 0, {
 #ifndef EXTERNAL_ZLIB
@@ -169,25 +165,20 @@ void set_allow_inc_recurse(void)
 
 void parse_compress_choice(int final_call)
 {
-       int num;
-
        if (valid_compressions.negotiated_name)
-               num = valid_compressions.negotiated_num;
+               do_compression = valid_compressions.negotiated_num;
        else if (compress_choice) {
                struct name_num_item *nni = get_nni_by_name(&valid_compressions, compress_choice, -1);
                if (!nni) {
                        rprintf(FERROR, "unknown compress name: %s\n", compress_choice);
                        exit_cleanup(RERR_UNSUPPORTED);
                }
-               num = nni->num;
+               do_compression = nni->num;
        } else
-               num = CPRES_NONE;
+               do_compression = CPRES_NONE;
 
-       if (num == CPRES_NONE) {
-               do_compression = 0;
+       if (do_compression == CPRES_NONE)
                compress_choice = NULL;
-       } else if (num > 0)
-               do_compression = num != CPRES_ZLIB ? 2 : 1;
 
        if (final_call && DEBUG_GTE(NSTR, am_server ? 2 : 1)) {
                const char *c_s = am_server ? "Server" : "Client";
index 427959f38b0fad7f04dcc5be1dfaae09d22f9fe4..e22e17e91439452a3390fc594f28e015024452b1 100644 (file)
@@ -397,7 +397,7 @@ else
     AC_MSG_RESULT(no)
 fi
 
-AC_MSG_CHECKING([whether to enable the xxhash support])
+AC_MSG_CHECKING([whether to enable xxhash checksum support])
 AC_ARG_ENABLE([xxhash],
        AS_HELP_STRING([--disable-xxhash],[disable xxhash checksums]))
 AH_TEMPLATE([SUPPORT_XXHASH],
diff --git a/flist.c b/flist.c
index a1b3e4bb8d224e7060958efcc77f393909605688..7e08fd4057a437082636ee2566eda24c8c32d173 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -142,7 +142,7 @@ void init_flist(void)
                rprintf(FINFO, "FILE_STRUCT_LEN=%d, EXTRA_LEN=%d\n",
                        (int)FILE_STRUCT_LEN, (int)EXTRA_LEN);
        }
-       parse_checksum_choice(1); /* Sets checksum_type && xfersum_type */
+       parse_checksum_choice(1); /* Sets checksum_type & xfersum_type */
        parse_compress_choice(1); /* Sets do_compression */
        flist_csum_len = csum_len_for_type(checksum_type, 1);
 
index 469b9fb6ea8806a9b899dbef3c33d88c3f368341..ff8c390e4d0468f797213bb3510400f1aa3dab04 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1968,7 +1968,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
        if (!compress_choice && do_compression > 1)
                compress_choice = "zlibx";
        if (compress_choice && strcasecmp(compress_choice, "auto") != 0)
-               parse_compress_choice(0); /* Can twiddle do_compression and possibly NULL-out compress_choice  */
+               parse_compress_choice(0); /* Twiddles do_compression and can possibly NULL-out compress_choice. */
        else
                compress_choice = NULL;
 
@@ -1983,7 +1983,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                        do_compression = 0;
                        compress_choice = NULL;
                } else if (!do_compression)
-                       do_compression = 1;
+                       do_compression = CPRES_ZLIB;
                if (do_compression && refused_compress) {
                        create_refuse_error(refused_compress);
                        return 0;
@@ -2628,7 +2628,7 @@ void server_options(char **args, int *argc_p)
        }
        if (sparse_files)
                argstr[x++] = 'S';
-       if (do_compression == 1)
+       if (do_compression == CPRES_ZLIB)
                argstr[x++] = 'z';
 
        set_allow_inc_recurse();
@@ -2765,9 +2765,9 @@ void server_options(char **args, int *argc_p)
                args[ac++] = arg;
        }
 
-       if ((!compress_choice && do_compression > 1) || (compress_choice && strcasecmp(compress_choice, "zlibx") == 0))
+       if (do_compression == CPRES_ZLIBX)
                args[ac++] = "--new-compress";
-       else if (compress_choice && strcasecmp(compress_choice, "zlib") == 0)
+       else if (compress_choice && do_compression == CPRES_ZLIB)
                args[ac++] = "--old-compress";
        else if (compress_choice) {
                if (asprintf(&arg, "--compress-choice=%s", compress_choice) < 0)
diff --git a/rsync.h b/rsync.h
index 5cf75fa7e38b2dbda1c03ed893cc5b963df5cb1f..cffd0d8e26f650509f474e17e434b4da51ac23ce 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -1061,6 +1061,10 @@ typedef struct {
 #define ACL_READY(sx) ((sx).acc_acl != NULL)
 #define XATTR_READY(sx) ((sx).xattr != NULL)
 
+#define CPRES_NONE 0
+#define CPRES_ZLIB 1
+#define CPRES_ZLIBX 2
+
 struct name_num_item {
        int num;
        const char *name, *main_name;
diff --git a/token.c b/token.c
index 1fdfa425588bafd71e04895065ac33459f11e948..c1de27f0d1993204507ae5be97c5958d134c6a79 100644 (file)
--- a/token.c
+++ b/token.c
@@ -300,8 +300,8 @@ static void
 send_deflated_token(int f, int32 token, struct map_struct *buf, OFF_T offset,
                    int32 nb, int32 toklen)
 {
-       int32 n, r;
        static int init_done, flush_pending;
+       int32 n, r;
 
        if (last_token == -1) {
                /* initialization */
@@ -406,7 +406,7 @@ send_deflated_token(int f, int32 token, struct map_struct *buf, OFF_T offset,
        if (token == -1) {
                /* end of file - clean up */
                write_byte(f, END_FLAG);
-       } else if (token != -2 && do_compression == 1) {
+       } else if (token != -2 && do_compression == CPRES_ZLIB) {
                /* Add the data in the current block to the compressor's
                 * history and hash table. */
                do {
@@ -640,11 +640,10 @@ int32 recv_token(int f, char **data)
 {
        int tok;
 
-       if (!do_compression) {
+       if (!do_compression)
                tok = simple_recv_token(f,data);
-       } else {
+       else /* CPRES_ZLIB & CPRES_ZLIBX */
                tok = recv_deflated_token(f, data);
-       }
        return tok;
 }
 
@@ -653,6 +652,6 @@ int32 recv_token(int f, char **data)
  */
 void see_token(char *data, int32 toklen)
 {
-       if (do_compression == 1)
+       if (do_compression == CPRES_ZLIB)
                see_deflate_token(data, toklen);
 }