You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Doug MacEachern <do...@covalent.net> on 2002/06/19 18:39:08 UTC
apr_uuid is not thread safe
static void get_current_time(apr_uint64_t *timestamp)
{
/* ### this needs to be made thread-safe! */
apr_uint64_t time_now;
static apr_uint64_t time_last = 0;
static int fudge = 0;
any plans/thoughts on making it threadsafe?
Re: apr_uuid is not thread safe
Posted by Brian Pane <bp...@pacbell.net>.
On Wed, 2002-06-19 at 09:39, Doug MacEachern wrote:
>
> static void get_current_time(apr_uint64_t *timestamp)
> {
> /* ### this needs to be made thread-safe! */
>
> apr_uint64_t time_now;
> static apr_uint64_t time_last = 0;
> static int fudge = 0;
>
> any plans/thoughts on making it threadsafe?
How about something like this as a replacement for the
get_current_time() logic...
for (;;) {
gettimeofday(&now);
if (now > time_last) {
atomic_cas(&time_last, now, time_last);
if (atomic_cas succeeded) {
return now;
}
}
else {
now = time_last + 1;
atomic_cas(&time_last, now, time_last);
if (atomic_cas succeeded) {
return now;
}
}
}
--Brian
Re: apr_uuid is not thread safe
Posted by Doug MacEachern <do...@covalent.net>.
more problems:
static int uuid_state_seqnum;
static unsigned char uuid_state_node[NODE_LENGTH] = { 0 };