[ofw] [PATCH] complib/user: fix timer race conditions

Hefty, Sean sean.hefty at intel.com
Mon Jun 28 09:29:17 PDT 2010


> I have supplied programs that show that there is a leak, you can fill free
> to try them.

If you sent executables, they were stripped out of my email.

> I agree that the documentation is not good, but it is "obvious" that
> DeleteTimerQueue must be called.

To be clear, we're talking about DeleteTimerQueueTimer, not DeleteTimerQueue.

> See for example
> http://blogs.msdn.com/b/oldnewthing/archive/2004/12/23/331246.aspx

I don't follow their logic.  If the OS can't automatically clean up a one-shot timer, then there's no way our abstraction can...  The timer APIs seem pretty weak, and the documentation vague at best.

If we need matching calls to CreateTimerQueueTimer - DeleteTimerQueueTimer, and my patch assumed that we didn't, so it would have an issue, then I think the fix is to allocate a new structure:

struct timer_osd
{
	cl_timer_t *p_timer;
	HANDLE timer;
};

in cl_timer_trim() and pass that to the timer callback.  The callback calls DeleteTimerQueueTimer if it has not already been called for the timer in question.

- Sean



More information about the ofw mailing list