From 3d2c3b321ccf6af4078be8076d4720af825a5dd0 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 18 Jun 2013 18:15:43 +0200 Subject: [PATCH] Disable the blacklist by default The blacklist might hide errors and reduce the ability to do proper diagnostics. Note that in _csync_push_file, we kept csync_statedb_get_progressinfo because it is also used for the resume feature Also added output when a file has been blacklisted. --- src/CMakeLists.txt | 7 +++++++ src/csync_propagate.c | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 61fb0eeaa..f64ef32dc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,6 +48,13 @@ if(ICONV_FOUND AND WITH_ICONV) list(APPEND CSYNC_LINK_LIBRARIES ${ICONV_LIBRARIES}) endif() +set(BLACKLIST_ON_ERROR 0 CACHE BOOL + "If an errors occurs three times on the same file, do not attempt to process that file any further.") + +if(BLACKLIST_ON_ERROR) + add_definitions(-DBLACKLIST_ON_ERROR) +endif() + set(csync_SRCS csync.c csync_config.c diff --git a/src/csync_propagate.c b/src/csync_propagate.c index 42f630771..42f7508a9 100644 --- a/src/csync_propagate.c +++ b/src/csync_propagate.c @@ -163,10 +163,15 @@ static int _csync_push_file(CSYNC *ctx, csync_file_stat_t *st) { progress_info = csync_statedb_get_progressinfo(ctx, st->phash, st->modtime, st->md5); rep_bak = ctx->replica; +#ifdef BLACKLIST_ON_ERROR if (progress_info && progress_info->error > 3) { + CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, + "'%s' was blacklisted after %d errors: %s", + st->path, progress_info->error, progress_info->error_string); rc = 1; goto out; } +#endif if (progress_info) { CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, @@ -805,9 +810,13 @@ static int _csync_rename_file(CSYNC *ctx, csync_file_stat_t *st) { if(node) other = (csync_file_stat_t *) node->data; +#ifdef BLACKLIST_ON_ERROR if (other) { pi = csync_statedb_get_progressinfo(ctx, other->phash, other->modtime, other->md5); if (pi && pi->error > 3) { + CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, + "'%s' was blacklisted after %d errors: %s", + st->path, pi->error, pi->error_string); if (!st->error_string && pi->error_string) st->error_string = c_strdup(pi->error_string); if (!other->error_string && pi->error_string) @@ -816,6 +825,7 @@ static int _csync_rename_file(CSYNC *ctx, csync_file_stat_t *st) { goto out; } } +#endif switch (ctx->current) { case REMOTE_REPLICA: @@ -973,13 +983,18 @@ static int _csync_remove_file(CSYNC *ctx, csync_file_stat_t *st) { int rc = -1; csync_progressinfo_t *pi = NULL; +#ifdef BLACKLIST_ON_ERROR pi = csync_statedb_get_progressinfo(ctx, st->phash, st->modtime, st->md5); if (pi && pi->error > 3) { + CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, + "'%s' was blacklisted after %d errors: %s", + st->path, pi->error, pi->error_string); rc = 1; if (!st->error_string && pi->error_string) st->error_string = c_strdup(pi->error_string); goto out; } +#endif switch (ctx->current) { @@ -1044,13 +1059,18 @@ static int _csync_new_dir(CSYNC *ctx, csync_file_stat_t *st) { int rc = -1; csync_progressinfo_t *pi = NULL; +#ifdef BLACKLIST_ON_ERROR pi = csync_statedb_get_progressinfo(ctx, st->phash, st->modtime, st->md5); if (pi && pi->error > 3) { + CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, + "'%s' was blacklisted after %d errors: %s", + st->path, pi->error, pi->error_string); if (!st->error_string && pi->error_string) st->error_string = c_strdup(pi->error_string); rc = 1; goto out; } +#endif replica_bak = ctx->replica; @@ -1148,13 +1168,18 @@ static int _csync_sync_dir(CSYNC *ctx, csync_file_stat_t *st) { int rc = -1; csync_progressinfo_t *pi = NULL; +#ifdef BLACKLIST_ON_ERROR pi = csync_statedb_get_progressinfo(ctx, st->phash, st->modtime, st->md5); if (pi && pi->error > 3) { + CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, + "'%s' was blacklisted after %d errors: %s", + st->path, pi->error, pi->error_string); if (!st->error_string && pi->error_string) st->error_string = c_strdup(pi->error_string); rc = 1; goto out; } +#endif replica_bak = ctx->replica;