Il 16/04/2012 10:17, Pavel Dovgaluk ha scritto:
>  Coroutine *qemu_coroutine_self(void)
>  {
> +    Coroutine *current = qemu_coroutine_get_current();
> +
>      if (!current) {
> -        current = &leader.base;
> -        leader.fiber = ConvertThreadToFiber(NULL);
> +        CoroutineWin32 *co = g_malloc0(sizeof(*co));
> +        current = &co->base;
> +        co->fiber = ConvertThreadToFiber(NULL);
> +        qemu_coroutine_set_current(current);
>      }

This leaks the leader. :(

Unfortunately, Win32 TLS doesn't have destructors.  Windows 2003 and
Vista have fiber-local storage that does have destructors and would
solve the problem even more nicely.
http://msdn.microsoft.com/en-us/library/ms683146 says it's not in XP,
but http://blogs.msdn.com/b/slavao/archive/2005/02/28/381649.aspx says
it does.  Perhaps some recent service pack?  Stefan, do you have any ideas?

Paolo

Reply via email to