commit 0491cbc: [Fix] Fix http maps with no or invalid expires data
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed May 19 17:56:04 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-05-19 18:47:22 +0100
URL: https://github.com/rspamd/rspamd/commit/0491cbc3f9bf154002902e0a5fd70b842e90a2bb (HEAD -> master)
[Fix] Fix http maps with no or invalid expires data
---
src/libserver/maps/map.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/libserver/maps/map.c b/src/libserver/maps/map.c
index da1995fab..bc53ca538 100644
--- a/src/libserver/maps/map.c
+++ b/src/libserver/maps/map.c
@@ -366,6 +366,10 @@ http_map_finish (struct rspamd_http_connection *conn,
map->next_check = hdate;
}
+ else {
+ msg_info_map ("invalid expires header: %T, ignore it", expires_hdr);
+ map->next_check = 0;
+ }
}
/* Check for etag */
@@ -514,6 +518,10 @@ http_map_finish (struct rspamd_http_connection *conn,
if (hdate != (time_t)-1 && hdate > msg->date) {
map->next_check = hdate;
}
+ else {
+ msg_info_map ("invalid expires header: %T, ignore it", expires_hdr);
+ map->next_check = 0;
+ }
}
etag_hdr = rspamd_http_message_find_header (msg, "ETag");
@@ -531,8 +539,8 @@ http_map_finish (struct rspamd_http_connection *conn,
rspamd_http_date_format (next_check_date, sizeof (next_check_date),
map->next_check);
msg_info_map ("data is not modified for server %s, next check at %s "
- "(http cache based)",
- cbd->data->host, next_check_date);
+ "(http cache based: %T)",
+ cbd->data->host, next_check_date, expires_hdr);
}
else {
rspamd_http_date_format (next_check_date, sizeof (next_check_date),
@@ -1036,6 +1044,7 @@ rspamd_map_schedule_periodic (struct rspamd_map *map, int how)
if (map->non_trivial && map->next_check != 0) {
timeout = map->next_check - rspamd_get_calendar_ticks ();
+ map->next_check = 0;
if (timeout > 0 && timeout < map->poll_timeout) {
/* Early check case, jitter */
@@ -1075,6 +1084,7 @@ rspamd_map_schedule_periodic (struct rspamd_map *map, int how)
}
}
else {
+ /* No valid information when to check a map, plan a timer based check */
timeout = map->poll_timeout;
if (how & RSPAMD_MAP_SCHEDULE_INIT) {
@@ -1617,7 +1627,15 @@ rspamd_map_read_http_cached_file (struct rspamd_map *map,
return FALSE;
}
- map->next_check = header.next_check;
+ double now = rspamd_get_calendar_ticks ();
+
+ if (header.next_check > now) {
+ map->next_check = header.next_check;
+ }
+ else {
+ map->next_check = now;
+ }
+
htdata->last_modified = header.mtime;
if (header.etag_len > 0) {
More information about the Commits
mailing list