| 180 | } |
| 181 | |
| 182 | void parse_compress_choice(int final_call) |
| 183 | { |
| 184 | if (valid_compressions.negotiated_nni) |
| 185 | do_compression = valid_compressions.negotiated_nni->num; |
| 186 | else if (compress_choice) { |
| 187 | struct name_num_item *nni = get_nni_by_name(&valid_compressions, compress_choice, -1); |
| 188 | if (!nni) { |
| 189 | rprintf(FERROR, "unknown compress name: %s\n", compress_choice); |
| 190 | exit_cleanup(RERR_UNSUPPORTED); |
| 191 | } |
| 192 | do_compression = nni->num; |
| 193 | if (am_server) |
| 194 | validate_choice_vs_env(NSTR_COMPRESS, do_compression, -1); |
| 195 | } else if (do_compression) |
| 196 | do_compression = CPRES_ZLIB; |
| 197 | else |
| 198 | do_compression = CPRES_NONE; |
| 199 | |
| 200 | if (do_compression != CPRES_NONE && final_call) |
| 201 | init_compression_level(); /* There's a chance this might turn compression off! */ |
| 202 | |
| 203 | if (do_compression == CPRES_NONE) |
| 204 | compress_choice = NULL; |
| 205 | |
| 206 | /* Snag the compression name for both write_batch's option output & the following debug output. */ |
| 207 | if (valid_compressions.negotiated_nni) |
| 208 | compress_choice = valid_compressions.negotiated_nni->name; |
| 209 | else if (compress_choice == NULL) { |
| 210 | struct name_num_item *nni = get_nni_by_num(&valid_compressions, do_compression); |
| 211 | compress_choice = nni ? nni->name : "UNKNOWN"; |
| 212 | } |
| 213 | |
| 214 | if (final_call && DEBUG_GTE(NSTR, am_server ? 3 : 1) |
| 215 | && (do_compression != CPRES_NONE || do_compression_level != CLVL_NOT_SPECIFIED)) { |
| 216 | rprintf(FINFO, "%s%s compress: %s (level %d)\n", |
| 217 | am_server ? "Server" : "Client", |
| 218 | valid_compressions.negotiated_nni ? " negotiated" : "", |
| 219 | compress_choice, do_compression_level); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | struct name_num_item *get_nni_by_name(struct name_num_obj *nno, const char *name, int len) |
| 224 | { |
no test coverage detected