modules/mpd: fix reconnect when we're not using inotify

When we're not able to use inotify, we rely on polling. However, we
never detected poll() timeouts, which meant we never re-attempted to
reconnect to MPD.

Maybe #394
This commit is contained in:
Daniel Eklöf 2024-08-20 07:32:51 +02:00
parent 3e0a65f185
commit 568eb1140f
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 10 additions and 2 deletions

View file

@ -36,6 +36,8 @@
* network: fix missing break in switch statement ([#377][377]).
* i3/sway: crash when output is turned off an on ([#300][300]).
* mpd: yambar never attempting to reconnect after MPD closed the
connection (for example, when MPD is restarted).
[377]: https://codeberg.org/dnkl/yambar/issues/377
[300]: https://codeberg.org/dnkl/yambar/issues/300

View file

@ -437,7 +437,7 @@ run(struct module *mod)
*/
while (!aborted) {
struct pollfd fds[] = {{.fd = mod->abort_fd, .events = POLLIN}};
int res = poll(fds, sizeof(fds) / sizeof(fds[0]), 10 * 1000);
int res = poll(fds, sizeof(fds) / sizeof(fds[0]), 2 * 1000);
if (res < 0) {
if (errno == EINTR)
@ -448,10 +448,16 @@ run(struct module *mod)
break;
}
if (res == 1) {
if (res == 0) {
ret = 0;
break;
}
else if (res == 1) {
assert(fds[0].revents & POLLIN);
aborted = true;
}
}
}