Hi There,
I am running apache 2.0.48 and I noticed sometimes multiple threads could access the counter "cur_unique_id.counter" without proper synchronization.
In more details, an automatic tool I developed found after one thread write the counter at line 389:
cur_unique_id.counter = htons(counter);
another thread could read the same counter at line 347:
new_unique_id.counter = cur_unique_id.counter;
And in between of these two accesses no synchronizations are observed.
Could this be a bug, or it is an correct behavior?
From the source code:
typedef struct {
unsigned int stamp;
unsigned int in_addr;
unsigned int pid;
unsigned short counter;
unsigned int thread_index;
} unique_id_rec;/* We are using thread_index (the index into the scoreboard), because we * cannot guarantee the thread_id will be an integer. * * This code looks like it won't give a unique ID with the new thread logic. * It will. The reason is, we don't increment the counter in a thread_safe * manner. Because the thread_index is also in the unique ID now, this does * not matter. In order for the id to not be unique, the same thread would * have to get the same counter twice in the same second. */
