Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enter_idle doesn't (immediately) handle signals when timing out #230

Open
unhammer opened this issue Jun 22, 2021 · 4 comments
Open

enter_idle doesn't (immediately) handle signals when timing out #230

unhammer opened this issue Jun 22, 2021 · 4 comments

Comments

@unhammer
Copy link

If I disconnect (unplug the network or whatever) while in IDLE, and then signal USR1, it doesn't handle the signal immediately, but instead waits for the timeout (or until plugged in again). This seems to happen often when switching wifi networks. It'd be nice if USR1 could make enter_idle leave that "waiting for network" state as well.

@lefcha
Copy link
Owner

lefcha commented Jun 22, 2021

Hm, this is strange because the enter_idle() was specifically designed to interrupt, and return immediately on the user signals. From the imapfilter_config(5) man page:

Apart from an event received by the server, the SIGUSR1 or SIGUSR2 signals can also interrupt the IDLE mode at any time, and the execution of the configuration file will then continue from the next line after the enter_idle(). In this case only the value “true” is returned.

Probably there's some bug that I need to fix there, so I'll have a look...

@lefcha
Copy link
Owner

lefcha commented Jun 22, 2021

It seems to work as expected for me. With a config like this:

myaccount = IMAP { ... }
print(myaccount.INBOX:enter_idle())

On a terminal I start imapfilter with imapfilter -v:

$ imapfilter -v
[...]
C (3): 1005 SELECT "INBOX"
S (3): 1005 OK [READ-WRITE] Select completed (0.001 + 0.000 secs).
C (3): 1006 IDLE

I then do pkill -SIGUSR1 imapfilter, and the signal causes IDLE to be stopped immediately:

S (3): 1006 OK Idle completed (1.291 + 1.291 + 1.290 secs).
true
C (3): 1007 LOGOUT
S (3): 1007 OK Logout completed (0.001 + 0.000 secs).
$ 

Can you provide an example or some details/steps on how I could reproduce the behavior you get?

@unhammer
Copy link
Author

idledevice
is when disconnecting – notice how there's a delay while waiting for the network to come up again. This is fine I suppose.

But what if I change to a new network:
newnetwork
now it waits for some long timeout (1 minute?) before finally exiting the idle state, even though I am online.

@lefcha
Copy link
Owner

lefcha commented Sep 19, 2021

Hm, I couldn't reproduce by disconnecting my wired connection. I need to try on a laptop with wireless connection, in case that makes a difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants