[libvirt] [PATCH] Include a thread identifier in log messages

Matthias Bolte matthias.bolte at googlemail.com
Mon Nov 22 19:02:45 UTC 2010


2010/11/22 Daniel P. Berrange <berrange at redhat.com>:
> To allow messages from different threads to be untangled,
> include an integer thread identifier in log messages.
>

> +int virThreadSelfID(void)
> +{
> +    HANDLE handle = GetCurrentThread();
> +    HANDLE process = GetCurrentProcess();
> +    HANDLE thread;
> +    int id;
> +
> +    DuplicateHandle(process, handle, process,
> +                    &thread, 0, FALSE,
> +                    DUPLICATE_SAME_ACCESS);
> +    id = (int)thread;
> +    CloseHandle(thread);
> +    return id;
> +}

You could use GetCurrentThreadId() here instead of the handle value.

Matthias




More information about the libvir-list mailing list