On 1/17/11 9:28 PM, Blair Zajac wrote:
> On 1/17/11 8:42 PM, Blair Zajac wrote:
> The random implementation seems a little harder, for a portable one, possible
> implementations:
>
> 1) apr_generate_random_bytes()
> On Unix, this opens DEV_RANDOM, which seems heavy for this issue.
>
> 2) apr_md5_init()
> Hash the current time and lock file path would be good enough, then xor the
> high 8 bytes into the low 8 bytes and then modulo 100ms.
Talking to myself here, I decided to go with a 32-bit FNV-1a implementation to
hash apr_time_now() each time apr_file_open(APR_EXCL) fails. Much cheaper than
an md5.
This code is in the public domain:
http://isthe.com/chongo/tech/comp/fnv/
Any issues copying implementation into svn? From
http://isthe.com/chongo/src/fnv/fnv.h
* Please do not copyright this code. This code is in the public domain.
*
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* By:
* chongo <Landon Curt Noll> /\oo/\
* http://www.isthe.com/chongo/
*
* Share and Enjoy! :-)
Blair
Received on 2011-01-18 08:35:34 CET