Re: [netatalk-admins] DIDs - an idea -or- I didn't read the AFP specs completely yet


Subject: Re: [netatalk-admins] DIDs - an idea -or- I didn't read the AFP specs completely yet
From: Gary E. Bickford (garyb@slb.com)
Date: Wed Apr 15 1998 - 17:45:44 EDT


Time has only one-second granularity. This is OK for many things, but
(IMHO) not quite enough for very active servers. There are some "unique"
functions around based on a combination of time and system clock that would
work, however.

There is a function called uniqid () in the PHP source library (available
under the GNU license at http://php.iquest.net, or http://www.php.net for
the new version 3), which uses gettimeofday. This code is not directly
usable, as it is specific to the PHP data structures. but may be useful to
someone on the list.

   gettimeofday((struct timeval *)&tv, (struct timezone *)NULL);
    sec = (int)tv.tv_sec;
    usec = (int)(tv.tv_usec % 1000000);

    /* The max value usec can have is 0xF423F, so we use only five hex
     * digits for usecs:
     */
    sprintf(uniqid, "%s%08x%05x", prefix, sec, usec);
    Push(uniqid, STRING);

GEB

At 3:00 PM -0500 4/15/98, Incze Lajos wrote:
>> For we can not use a DID number we already used, we should maintain a
>> 'high water mark' for the volume, like .maxDID or .AppleDouble/.maxDID.
>> When we create a directory (or find one without a DID, like one created in
>> unix), we assign maxDID to its DID, store it as - let's say -
>> .AppleDouble/.DID, and then bump .maxDID.
>
>My idea was to use the unsigned long returned by time(). Then the
>TIME will maintain your uniqness. And no need for the .maxDID bump
>which has a race condition.
>
>> This seems to be too simple for me to believe it's right.
>
>Seems to work. Incze



This archive was generated by hypermail 2b28 : Sat Dec 18 1999 - 16:32:22 EST