skelband at gmail.com
Mon Aug 29 01:19:06 BST 2022
A few users have commented here:
...that the conversion of sanei_thread to use processes instead of
threads has effectively broken scanning on the on some platforms.
Apparently, there is a reference to a long standing issue identified in
the implementation and use of the sanei_thread API.
In particular, I think that there are a few issues:
1. There are assumptions that pthread_t is arithmetic.
2. Some backends are assuming that SANE_Pid is a pthread_t and abusing
3. Despite the warnings about comparing pthread_ts directly, we do have
a few instances where code is not using pthread_equal() or a
4. There is no cross-platform method for determining if a SANE_Pid is
"valid", which is where some of the above backend issues come from.
So I have tried to come up with a solution that I believe doesn't
strictly break API compatibility although because of some of the
aforementioned issues, there are breaking changes to some of the backends.
The idea is to replace the existing SANE_Pid with a structure:
Because this is now a structure, invalid direct comparison of SANE_Pid
using == now raises a compile error.
Additionally, with the addition of a new is_valid flag, we can indicate
if the enclosed pid member has a valid value.
The ramifications of this internal change should be entirely confined to
sanei_thread but a few backends required some small changes.
See https://gitlab.com/sane-project/backends/-/issues/153 for some
I have drafted up this change, although I haven't performed much in the
way of testing with machines yet (I will!) here:
I accept that some 3rd-party builds might be a broken slightly by this
change, but that would surely be due to one or more of the abuses of the
API mentioned above.
I would appreciate comments on the general strategy and reviews of the code.
More information about the sane-devel