message is identical (mutans mutatis) to that in the logs posted here, but
in my case `scanimage -L` shows that the device name has not changed.
Nonetheless, sane is still returning SANE_STATUS_INVAL.
I have turned on debug output in scanbd, and looked at the source code, but
I can't see why the call to sane_open is succeeding the first time, but not
subsequently. It might be worth debugging inside libsane to make progress,
but I'd welcome assistance from experts!
For now, I added an rsyslog filter that runs a program to restart scanbd
whenever it logs an "abandon" message.
This in itself requires a few steps:
1. Compile the following C program, setuid, as
/usr/local/sbin/restart-scanbd:
#include <stdlib.h>
int main (void)
{
system ("sudo systemctl restart scanbd.service");
}
2. Write the rsyslog filter to execute it (/etc/rsyslog.d/99-scanbd):
:msg, regex, "/usr/sbin/scanbd: abandon polling of"
^/usr/local/sbin/restart-scanbd
3. Edit systemd's unit for rsyslog to add "NotifyAccess=all" (sudo
systemctl edit rsyslog), otherwise the filter doesn't get executed.
4. Run visudo and add the following to /etc/sudoers:
# Allow syslog to restart scanbd
syslog ALL=(root) NOPASSWD: /usr/bin/systemctl restart scanbd.service
It's a painful workaround, but for me it worked flawlessly.