[ovs-dev] [PATCH v2 1/1] ovs-thread: Fix thread id for threads not started with ovs_thread_create()
Eelco Chaudron
echaudro at redhat.com
Tue May 29 08:23:12 UTC 2018
On 05/28/2018 03:42 PM, Ilya Maximets wrote:
> On 28.05.2018 14:06, Eelco Chaudron wrote:
<SNIP>
>> +unsigned int
>> +ovsthread_id_init(void)
>> +{
>> + static atomic_count next_id = ATOMIC_COUNT_INIT(0);
>> +
>> + unsigned int id = *ovsthread_id_get();
>> +
>> + if (id == OVSTHREAD_ID_UNSET) {
> I'm not sure, if we need to check the id here. I think, 'init' function
> should not be called twice. Also, you're checking the id before calling.
I don't think checking before calling should be an issue, it will return
the default.
> How about just adding the assert?
I'm not a big fan of assert, especially in recoverable situations. This
way calling the function twice will not hurt. Also, this function should
never be called by the application code directly.
But if assert is a common practice in OVS, I can go ahead and change it.
>> + id = atomic_count_inc(&next_id);
>> + *ovsthread_id_get() = id;
>> + }
>> +
>> + return id;
>> +}
>> +
>>
More information about the dev
mailing list