diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-05 13:50:51 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-05 13:50:51 +0100 |
commit | c675ccabe6013858516a9bdab3698417a041ea8e (patch) | |
tree | 3aa25f29ca7103313cb2860b345c33115f8b9d3e /src/plugins/fuzzy_check.c | |
parent | c16a377102234ecf82e00273e4faf4371fe0e8bd (diff) | |
download | rspamd-c675ccabe6013858516a9bdab3698417a041ea8e.tar.gz rspamd-c675ccabe6013858516a9bdab3698417a041ea8e.zip |
Try to fix fuzzy learning states (not fully completed).
Diffstat (limited to 'src/plugins/fuzzy_check.c')
-rw-r--r-- | src/plugins/fuzzy_check.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index cdd575136..8b5c2ee58 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -1117,33 +1117,42 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg) event_set (&session->ev, fd, EV_READ, fuzzy_controller_io_callback, session); event_add (&session->ev, NULL); + return; } else if (ret == -1) { msg_err_task ("got error in IO with server %s, %d, %s", rspamd_upstream_name (session->server), errno, strerror (errno)); - - goto cleanup; + rspamd_upstream_fail (session->server); } - else { - (*session->saved)--; - if (*session->saved == 0) { - goto cleanup; - } - else { - /* Read more */ - event_del (&session->ev); - event_set (&session->ev, fd, EV_READ, - fuzzy_controller_io_callback, session); - event_add (&session->ev, NULL); - } + /* + * XXX: actually, we check merely a single reply, which is not correct... + * XXX: when we send a command, we do not check if *all* commands have been + * written + * XXX: please, please, change this code some day + */ + (*session->saved)--; + rspamd_http_connection_unref (session->http_entry->conn); + event_del (&session->ev); + event_del (&session->timev); + close (session->fd); + + if (*session->saved == 0) { + goto cleanup; } return; cleanup: + /* + * When we send learn commands to fuzzy storages, this code is executed + * *once* when we have queried all storages. We also don't know which + * storage has been failed. + * + * Therefore, we cleanup sessions earlier and actually this code is wrong. + */ + if (*(session->err) != NULL) { - rspamd_upstream_fail (session->server); rspamd_controller_send_error (session->http_entry, (*session->err)->code, (*session->err)->message); g_error_free (*session->err); @@ -1155,10 +1164,7 @@ cleanup: } rspamd_task_free (session->task, TRUE); - rspamd_http_connection_unref (session->http_entry->conn); - event_del (&session->ev); - event_del (&session->timev); - close (session->fd); + } static void |