From af1aa4b05de3e88918869b8867e182df09010574 Mon Sep 17 00:00:00 2001
From: Benedikt Spranger <bene@eurovibes.org>
Date: Thu, 7 May 2020 00:12:27 +0200
Subject: [PATCH 1/2] Fix key expire function

The key expire function failed with

RuntimeError: dictionary changed size during iteration

Python 3 did not act on a copy while iterating over a dictionary any
more. Instead a iterator is used. Removing elements from the dictionary
will fail and throw the given exception.

Iterate over a copy of the dictionary.

Signed-off-by: Benedikt Spranger <bene@eurovibes.org>
---
 program/greylistd | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/program/greylistd b/program/greylistd
index 45e24dc8dc31..32db9ef453e6 100755
--- a/program/greylistd
+++ b/program/greylistd
@@ -106,7 +106,7 @@ def expireKeys (now):
     for (listKey, timeoutKey) in ((GREY,  RETRYMAX),
                                   (WHITE, EXPIRE),
                                   (BLACK, EXPIRE)):
-        for (dataKey, dataValue) in data[listKey].items():
+        for (dataKey, dataValue) in data[listKey].copy()items():
             if dataValue[IDX_LAST] + config[TIMEOUTS][timeoutKey] < now:
                 del data[listKey][dataKey]
 
-- 
2.26.2

