{
guint i;
struct rspamd_statfile *st;
- struct rspamd_classifier *cl;
gpointer bk_run;
g_assert (task->stat_runtimes != NULL);
for (i = 0; i < st_ctx->statfiles->len; i++) {
st = g_ptr_array_index (st_ctx->statfiles, i);
- cl = st->classifier;
bk_run = g_ptr_array_index (task->stat_runtimes, i);
if (bk_run != NULL) {
gpointer bk_run;
guint i, j;
gint id;
- gboolean res = FALSE;
+ gboolean res = FALSE, backend_found = FALSE;
for (i = 0; i < st_ctx->classifiers->len; i ++) {
cl = g_ptr_array_index (st_ctx->classifiers, i);
goto end;
}
- msg_warn_task ("no runtime for backend %s; classifier %s; symbol %s",
+ msg_debug_task ("no runtime for backend %s; classifier %s; symbol %s",
st->backend->name, cl->cfg->name, st->stcf->symbol);
continue;
}
+ /* We set sel merely when we have runtime */
+ backend_found = TRUE;
+
if (!(task->flags & RSPAMD_TASK_FLAG_UNLEARN)) {
if (!!spam != !!st->stcf->is_spam) {
/* If we are not unlearning, then do not touch another class */
}
end:
- if (!res && err) {
- return res;
- }
- if (!res && sel == NULL) {
- if (classifier) {
- g_set_error (err, rspamd_stat_quark (), 404, "cannot find classifier "
- "with name %s", classifier);
- }
- else {
- g_set_error (err, rspamd_stat_quark (), 404, "no classifiers defined");
+ if (!res) {
+ if (err && *err) {
+ /* Error has been set already */
+ return res;
}
- return FALSE;
- }
+ if (sel == NULL) {
+ if (classifier) {
+ g_set_error(err, rspamd_stat_quark(), 404, "cannot find classifier "
+ "with name %s", classifier);
+ }
+ else {
+ g_set_error(err, rspamd_stat_quark(), 404, "no classifiers defined");
+ }
- if (!res) {
- g_set_error (err, rspamd_stat_quark (), 404, "cannot find statfile "
- "backend to learn %s in %s", spam ? "spam" : "ham",
- classifier ? classifier : "default classifier");
+ return FALSE;
+ }
+ else if (!backend_found) {
+ g_set_error(err, rspamd_stat_quark(), 404, "all learn conditions "
+ "denied learning %s in %s",
+ spam ? "spam" : "ham",
+ classifier ? classifier : "default classifier");
+ }
+ else {
+ g_set_error(err, rspamd_stat_quark(), 404, "cannot find statfile "
+ "backend to learn %s in %s",
+ spam ? "spam" : "ham",
+ classifier ? classifier : "default classifier");
+ }
}
return res;