Fix another interesting bug. td_threadq is shared by the LWKT scheduler,
tsleep, and port-blocking code. Because of this separate flags exist to
indicate which queue the thread currently resides on and careful sanity
checks were added to prevent corruption.
The thread scheduler will not enqueue a thread that is sitting on one of
these other queues. This commit fixes a bug where the preemption code
would still preemptively switch into the thread even when the enqueue fails,
causing an assertion to be hit in tsleep().
This just goes to show that asserting on supposedly impossible conditions is
a good idea :-).
Reported-by: Stefan Krueger <skrueger@meinberlikomm.de>