CLEANUP: item_start_scrub() function.
@@ -7864,8 +7864,10 @@ bool item_start_scrub(struct default_engine *engine, int mode, bool autorun)
assert(mode == (int)SCRUB_MODE_NORMAL || mode == (int)SCRUB_MODE_STALE);
bool restarted = false;
bool ret = false;
+
pthread_mutex_lock(&engine->scrubber.lock);
- if (engine->scrubber.enabled && !engine->scrubber.running) {
+ if (engine->scrubber.enabled) {
+ if (!engine->scrubber.running) {
engine->scrubber.started = time(NULL);
engine->scrubber.stopped = 0;
engine->scrubber.visited = 0;
@@ -7885,14 +7887,15 @@ bool item_start_scrub(struct default_engine *engine, int mode, bool autorun)
} else {
ret = true;
}
- }
- else if (engine->scrubber.enabled && autorun == true
- && mode == SCRUB_MODE_STALE) {
+ } else {
+ if (autorun == true && mode == SCRUB_MODE_STALE) {
restarted = true;
engine->scrubber.restart = restarted;
engine->scrubber.runmode = (enum scrub_mode)mode;
ret = true;
}
+ }
+ }
pthread_mutex_unlock(&engine->scrubber.lock);
if (ret) {
@@ -7901,11 +7904,19 @@ bool item_start_scrub(struct default_engine *engine, int mode, bool autorun)
"Scrub is succesfully started.\n");
} else {
logger->log(EXTENSION_LOG_INFO, NULL,
- "Scrub is arleady running. Restart scrub.n");
+ "Scrub is arleady running. Restarted the scrub.\n");
}
} else {
+ if (!engine->scrubber.enabled) {
+ logger->log(EXTENSION_LOG_WARNING, NULL,
+ "Failed to start scrub. Scrub is disabled.\n");
+ } else if (engine->scrubber.running) {
logger->log(EXTENSION_LOG_WARNING, NULL,
"Failed to start scrub. Scrub is already running.\n");
+ } else {
+ logger->log(EXTENSION_LOG_WARNING, NULL,
+ "Failed to start scrub. Scrub thread creation problem.\n");
+ }
}
return ret;
}
