[Snort-devel] THREAD_LOCAL

Sancho Panza sancho at ...3553...
Fri Jan 23 10:26:14 EST 2015

I am currently working myself through the source code of Snort++ 
I saw that there are quite a few variables are declared to be 
"THREAD_LOCAL", for example

THREAD_LOCAL SnortConfig* snort_conf = nullptr;

Alas, this is only just a pointer, and I believe, that as soon as space 
is allocated for that variable during parsing and initialisation, the 
assignments made thereto are made with memory allocated on a per-process 
level, not on a per-thread level.
Is this correct or am I missing something?
If I'm right, then what's the point of declaring snort_conf 

Suppose I want to write my own rule detection option MyOption (inhering 
from IpsOption), is it safe to declare member variables inside MyOption 
and modify those during eval() without having to fear the threads might 
get in each others way, i.e. does every thread have its own instances of 
every IpsOption?

Many thanks


More information about the Snort-devel mailing list