[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



2010/11/22 Daniel P. Berrange <berrange 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]