I have made a patch that actually deletes 500 ms delay from mailbox-watch.c rather than reducing it to 1 ms.
I then looked into adding debounce to src/imap/cmd-idle.c, but there I cannot be sure that mailbox pointer passed to idle_callback() will not be freed by the time debounce timer expires. If we want to have debounce in IDLE, it should be kept in mailbox-watch.c, but reset via special API from cmd-idle.c every time IDLE is started.
Then I thought about the issue again and am pretty sure debounce is not needed for IDLE. If an offline client gets online and synchronizes a lot of flags, it usually can do it in one command. If it does not, because of bad implementation or because flags are different for different messages, it will send multiple commands. In this case IDLE-ing client will receive multiple updates, but this is not bad for performance. If IDLE-ing client does not ignore these updates and actually processes them, worst case it will immediately get busy processing the first incoming update. But by the time it finishes processing the first update it will receive many updates and process them in batch, effectively debouncing on the client even if there is no special code doing this.
So unless there is an IMAP client that is known to benefits from debouncing, I suggest that no debouncing is added for IDLE.
Alex (1): storage: remove 500 ms debounce on IMAP IDLE notifications
src/lib-storage/mail-storage-private.h | 2 +- src/lib-storage/mailbox-watch.c | 21 ++++----------------- 2 files changed, 5 insertions(+), 18 deletions(-)
-- 2.43.0