diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-05-11 16:03:40 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-05-11 16:03:40 +0400 |
commit | 6c632b961dcae8930b655bff8565f015dd9aa143 (patch) | |
tree | ea406be7a7cd6d22e7e95e2d175c81b9fc49e148 | |
parent | 3ebf213049f937b3fb4db45797f1a8861c0f94a6 (diff) | |
parent | a5b2977921dfdeee2cacdf4569dd662358775812 (diff) | |
download | rspamd-6c632b961dcae8930b655bff8565f015dd9aa143.tar.gz rspamd-6c632b961dcae8930b655bff8565f015dd9aa143.zip |
* Merge
-rw-r--r-- | src/controller.c | 6 | ||||
-rw-r--r-- | src/fuzzy_storage.c | 16 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/controller.c b/src/controller.c index 875bedbcc..d3c5e9e70 100644 --- a/src/controller.c +++ b/src/controller.c @@ -451,8 +451,8 @@ process_command (struct controller_command *cmd, char **cmd_args, struct control /* If uptime more than 2 hours, print as a number of days. */ if (uptime >= 2 * 3600) { days = uptime / 86400; - hours = uptime / 3600 - days * 3600; - minutes = uptime / 60 - hours * 60 - days * 3600; + hours = uptime / 3600 - days * 24; + minutes = uptime / 60 - hours * 60 - days * 1440; r = snprintf (out_buf, sizeof (out_buf), "%d day%s %d hour%s %d minute%s" CRLF, days, days > 1 ? "s" : " ", hours, hours > 1 ? "s" : " ", minutes, minutes > 1 ? "s" : " "); } /* If uptime is less than 1 minute print only seconds */ @@ -462,7 +462,7 @@ process_command (struct controller_command *cmd, char **cmd_args, struct control /* Else print the minutes and seconds. */ else { hours = uptime / 3600; - minutes = uptime / 60 - hours * 3600; + minutes = uptime / 60 - hours * 60; uptime -= hours * 3600 + minutes * 60; r = snprintf (out_buf, sizeof (out_buf), "%d hour%s %d minite%s %d second%s" CRLF, hours, hours > 1 ? "s" : " ", minutes, minutes > 1 ? "s" : " ", (int)uptime, uptime > 1 ? "s" : " "); } diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 3be999720..8957c9d35 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -668,6 +668,12 @@ accept_fuzzy_socket (int fd, short what, void *arg) struct rspamd_worker *worker = (struct rspamd_worker *)arg; struct fuzzy_session session; ssize_t r; + struct { + u_char cmd; + uint32_t blocksize; + int32_t value; + u_char hash[FUZZY_HASHLEN]; + } legacy_cmd; session.worker = worker; @@ -685,6 +691,16 @@ accept_fuzzy_socket (int fd, short what, void *arg) /* Assume that the whole command was read */ process_fuzzy_command (&session); } + else if (r == sizeof (legacy_cmd)) { + /* Process requests from old rspamd */ + memcpy (&legacy_cmd, session.pos, sizeof (legacy_cmd)); + session.cmd.cmd = legacy_cmd.cmd; + session.cmd.blocksize = legacy_cmd.blocksize; + session.cmd.value = legacy_cmd.value; + session.cmd.flag = 0; + memcpy (session.cmd.hash, legacy_cmd.hash, sizeof (legacy_cmd.hash)); + process_fuzzy_command (&session); + } else { msg_err ("got incomplete data while reading from socket: %d, %s", errno, strerror (errno)); return; |