httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dean gaudet <>
Subject Re: Apache-1.3: question about mod_unique_id
Date Fri, 14 Sep 2001 05:38:49 GMT

On Thu, 13 Sep 2001, Brad Nicholes wrote:

>    I checked with our CLIB people and they tell me that GetThreadID is
> *not* unique.  In other words, if a thread is created, it is assigned
> an ID.  If that thread is terminated and a new thread is created, the
> new thread may reuse the ID from the terminated thread.

sorry -- i meant unique across multiple processes ... that is process 1
and process 2 couldn't both have a thread 57.  (istr netware has processes
and has a global shared memory space...)

tid re-use is in principle a problem, but it requires a single thread to
serve thousands of requests per second (too lazy to do the math right
now).  but also i don't think we kill/restart threads in the 1.3
multithreaded server, so it's in practice not a problem at all.

> ok, sounds good. Then based on Dean's post and when Brad confirms that
> GetThreadID is always unique for NetWare we have only to add: #define
> gettid GetThreadID
> and in mod_unique_id.c we can remove the error warning and then change:
>     pid = getpid();
> to:
>     pid = gettid();
> #else
>     pid = getpid();
> #endif

no -- 'cause the tid is not unique in general in the way i was describing.
on unix it's possible to have pid 50 and pid 60 both with tid 1.  you need
the pid as well.  (we start multiple processes and multiple threads within
each in the 1.3 threaded server.)

> On the other side I saw that some other sources inside Apache use
> getpid(), is this not a problem there too? And if only Win32 has an
> insufficient getpid() definition, it may be enough to redefine this
> only there and leave all other as is...??

it's sufficient for most other uses...  the insufficiency is that there's
a thread-local counter in mod_unique_id (to avoid the need for a mutex)
and it needs the tid to distinguish its counts from other threads.


View raw message