Ok I located the source of the problem.

The code in main_loop_wait() that uses WaitForMultipleObjects will only 
service one object that woke it up.

What is occuring is that the host_alarm timer is being serviced anytime 
the tap_semaphore is also signaled, therefore the tap callback function is
never called while at the same time the tap_semaphore count is 
decremented. This guarantees that the callback function will never get 
services if that particular timing continues.

This is likely something that won't occur on every system because of the 
nature of the timing, but it is a problem.

I'm working on a better fix as right now my solution is to poll all the 
objects after a wakeup to see who really is signaled.
In order to do that you must use an Event Object in Manual Reset Mode.

vl.c

void main_loop_wait(int timeout)
...
        WaitObjects *w = &wait_objects;
 
        ret = WaitForMultipleObjects(w->num, w->events, FALSE, timeout);
        if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) 
{
            if (w->func[ret - WAIT_OBJECT_0])
                w->func[ret - WAIT_OBJECT_0](w->opaque[ret - 
WAIT_OBJECT_0]);
        } else if (ret == WAIT_TIMEOUT) {
        } else {
            err = GetLastError();
            fprintf(stderr, "Wait error %d %d\n", ret, err);
        }
...



Ely Soto


-----------------------------------------
Notice:  This e-mail is intended solely for use of the individual
or entity to which it is addressed and may contain information that
is proprietary, privileged and exempt from disclosure under
applicable law.  If the reader is not the intended recipient or
agent responsible for delivering the message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly
prohibited.  This communication may also contain data subject to
U.S. export laws.  If so, that data subject to the International
Traffic in Arms Regulation cannot be disseminated, distributed or
copied to foreign nationals, residing in the U.S. or abroad, absent
the express prior approval of the U.S. Department of State.   If
you have received this communication in error, please notify the
sender by reply e-mail and destroy the e-mail message and any
physical copies made of the communication.  Thank you.

Reply via email to