Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Data-UUID CPAN distribution.

Report information
The Basics
Id: 71497
Status: resolved
Priority: 0/
Queue: Data-UUID

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.217
Fixed in: (no value)



Subject: make _STDIR a variable based on File::Spec->tmpdir
Hi This patch makes _STDIR a variable based on File::Spec->tmpdir See attached patch Thanks
Subject: note-Data-UUID-1.217.patch.txt

Message body is not shown because it is too large.

The patch might be easier to read without ppport.h
Subject: note-Data-UUID-1.217.patch.noppport.txt
diff -ruN Data-UUID-1.217/Changes Data-UUID-1.21701/Changes --- Data-UUID-1.217/Changes 2010-09-13 18:47:32.000000000 -0700 +++ Data-UUID-1.21701/Changes 2011-02-28 07:54:08.000000000 -0800 @@ -1,5 +1,14 @@ Revision history for Perl extension Data::UUID. +1.21701 2011-02-28 + - added TODO + - these are now variables set once when UUID.pm is loaded, based on File::Spec->tmpdir + $Data::UUID::_STDIR + $Data::UUID::_DEFAULT_UMASK + $Data::UUID::UUID_NODEID_NV_STORE + $Data::UUID::UUID_STATE_NV_STORE + + 1.217 2010-09-14 - documentation fixes - minor portability tweak to UUID.xs (thanks, Florian Ragwitz) diff -ruN Data-UUID-1.217/Makefile.PL Data-UUID-1.21701/Makefile.PL --- Data-UUID-1.217/Makefile.PL 2009-11-03 13:46:03.000000000 -0800 +++ Data-UUID-1.21701/Makefile.PL 2011-02-28 07:28:05.000000000 -0800 @@ -84,9 +84,9 @@ chmod(0666, sprintf("%s/%s", $d, ".UUID_NODEID")); chmod(0666, sprintf("%s/%s", $d, ".UUID_STATE")); return { - DEFINE => qq(-D_STDIR=\\"$d\\") - . qq( -D__$Config{osname}__) - . qq( -D_DEFAULT_UMASK=$m) + DEFINE => qq( -D__$Config{osname}__) +#~ . qq(-D_STDIR=\\"$d\\") +#~ . qq( -D_DEFAULT_UMASK=$m) }; } ); diff -ruN Data-UUID-1.217/MANIFEST Data-UUID-1.21701/MANIFEST --- Data-UUID-1.217/MANIFEST 2010-09-13 18:48:13.000000000 -0700 +++ Data-UUID-1.21701/MANIFEST 2011-02-28 07:54:55.000000000 -0800 @@ -1,7 +1,9 @@ Changes LICENSE Makefile.PL -MANIFEST +MANIFEST This list of files +META.yml +ppport.h ptable.h README smp-test/collision.t @@ -13,8 +15,8 @@ t/pod.t t/segv.t t/threads.t +TODO typemap UUID.h UUID.pm UUID.xs -META.yml Module meta-data (added by MakeMaker) diff -ruN Data-UUID-1.217/META.yml Data-UUID-1.21701/META.yml --- Data-UUID-1.217/META.yml 2010-09-13 18:48:13.000000000 -0700 +++ Data-UUID-1.21701/META.yml 2011-02-28 07:55:00.000000000 -0800 @@ -1,6 +1,6 @@ --- #YAML:1.0 name: Data-UUID -version: 1.217 +version: 1.21701 abstract: Perl extension for generating Globally/Universally author: - Ricardo Signes <rjbs[at]cpan.org> diff -ruN Data-UUID-1.217/ptable.h Data-UUID-1.21701/ptable.h --- Data-UUID-1.217/ptable.h 2010-05-24 19:46:24.000000000 -0700 +++ Data-UUID-1.21701/ptable.h 2011-02-28 07:16:03.000000000 -0800 @@ -1,3 +1,4 @@ +#include "ppport.h" /* This file is part of the Variable::Magic Perl module. * See http://search.cpan.org/dist/Variable-Magic/ */ diff -ruN Data-UUID-1.217/TODO Data-UUID-1.21701/TODO --- Data-UUID-1.217/TODO 1969-12-31 16:00:00.000000000 -0800 +++ Data-UUID-1.21701/TODO 2011-02-28 07:54:49.000000000 -0800 @@ -0,0 +1,7 @@ + + +2011-02-28 +- Maybe use File::UserConfig/File::ConfigDir instead of File::Spec->tmpdir? +- Maybe update Makefile.PL so that setting/hardcoding _STDIR/_DEFAULT_UMASK works again + + diff -ruN Data-UUID-1.217/UUID.h Data-UUID-1.21701/UUID.h --- Data-UUID-1.217/UUID.h 2008-11-21 13:37:56.000000000 -0800 +++ Data-UUID-1.21701/UUID.h 2011-02-28 07:16:03.000000000 -0800 @@ -1,3 +1,4 @@ +#include "ppport.h" #if !defined __UUID_H__ # define __UUID_H__ @@ -5,7 +6,7 @@ #include <stdio.h> #include <stdlib.h> #ifndef _MSC_VER -// No unistd.h in MS VC +/* No unistd.h in MS VC */ #include <unistd.h> #endif #include <time.h> @@ -44,22 +45,6 @@ #include <process.h> #endif -#if !defined _STDIR -# define _STDIR "/var/tmp" -#endif -#if !defined _DEFAULT_UMASK -# define _DEFAULT_UMASK 0007 -#endif - -#define UUID_STATE ".UUID_STATE" -#define UUID_NODEID ".UUID_NODEID" -#if defined __mingw32__ || defined _WIN32 || defined _MSC_VER -#define UUID_STATE_NV_STORE _STDIR"\\"UUID_STATE -#define UUID_NODEID_NV_STORE _STDIR"\\"UUID_NODEID -#else -#define UUID_STATE_NV_STORE _STDIR"/"UUID_STATE -#define UUID_NODEID_NV_STORE _STDIR"/"UUID_NODEID -#endif #define UUIDS_PER_TICK 1024 #ifdef _MSC_VER @@ -92,7 +77,7 @@ typedef unsigned __int8 uint8_t; typedef unsigned __int64 unsigned64_t; -// http://msdn2.microsoft.com/en-us/library/296az74e.aspx - Integer Limits +/* http://msdn2.microsoft.com/en-us/library/296az74e.aspx - Integer Limits */ typedef int pid_t; #endif /* _MSC_VER */ diff -ruN Data-UUID-1.217/UUID.pm Data-UUID-1.21701/UUID.pm --- Data-UUID-1.217/UUID.pm 2010-09-13 18:47:44.000000000 -0700 +++ Data-UUID-1.21701/UUID.pm 2011-02-28 07:36:14.000000000 -0800 @@ -5,6 +5,7 @@ use Carp; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); + require Exporter; require DynaLoader; require Digest::MD5; @@ -19,8 +20,16 @@ NameSpace_URL NameSpace_X500 ); -$VERSION = '1.217'; +$VERSION = '1.21701'; +use File::Spec; +BEGIN { + use vars qw' $_STDIR $_DEFAULT_UMASK $UUID_STATE_NV_STORE $UUID_NODEID_NV_STORE '; + $_STDIR = File::Spec->canonpath( File::Spec->tmpdir ); + $_DEFAULT_UMASK = 0007; + $UUID_STATE_NV_STORE = File::Spec->canonpath( File::Spec->catdir( $_STDIR, ".UUID_STATE" )); + $UUID_NODEID_NV_STORE = File::Spec->canonpath( File::Spec->catdir( $_STDIR, ".UUID_NODEID" )); +} bootstrap Data::UUID $VERSION; 1; diff -ruN Data-UUID-1.217/UUID.xs Data-UUID-1.21701/UUID.xs --- Data-UUID-1.217/UUID.xs 2010-09-13 18:46:39.000000000 -0700 +++ Data-UUID-1.21701/UUID.xs 2011-02-28 07:24:07.000000000 -0800 @@ -1,6 +1,8 @@ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#define NEED_newCONSTSUB +#include "ppport.h" #include "UUID.h" @@ -341,13 +343,13 @@ mode_t mask; CODE: RETVAL = (uuid_context_t *)PerlMemShared_malloc(sizeof(uuid_context_t)); - if ((fd = fopen(UUID_STATE_NV_STORE, "rb"))) { + if ((fd = fopen(SvPVbyte_nolen(get_sv("Data::UUID::UUID_STATE_NV_STORE",0)), "rb"))) { fread(&(RETVAL->state), sizeof(uuid_state_t), 1, fd); fclose(fd); get_current_time(&timestamp); RETVAL->next_save = timestamp; } - if ((fd = fopen(UUID_NODEID_NV_STORE, "rb"))) { + if ((fd = fopen(SvPVbyte_nolen(get_sv("Data::UUID::UUID_NODEID_NV_STORE",0)), "rb"))) { pid_t *hate = (pid_t *) &(RETVAL->nodeid); fread(&(RETVAL->nodeid), sizeof(uuid_node_t), 1, fd ); fclose(fd); @@ -357,8 +359,8 @@ get_random_info(seed); seed[0] |= 0x80; memcpy(&(RETVAL->nodeid), seed, sizeof(uuid_node_t)); - mask = umask(_DEFAULT_UMASK); - if ((fd = fopen(UUID_NODEID_NV_STORE, "wb"))) { + mask = umask( SvIV( get_sv("Data::UUID::_DEFAULT_UMASK",0) )); + if ((fd = fopen(SvPVbyte_nolen(get_sv("Data::UUID::UUID_NODEID_NV_STORE",0)), "wb"))) { fwrite(&(RETVAL->nodeid), sizeof(uuid_node_t), 1, fd); fclose(fd); }; @@ -401,8 +403,8 @@ self->state.ts = timestamp; self->state.cs = clockseq; if (timestamp > self->next_save ) { - mask = umask(_DEFAULT_UMASK); - if((fd = fopen(UUID_STATE_NV_STORE, "wb"))) { + mask = umask( SvIV( get_sv("Data::UUID::_DEFAULT_UMASK",0) ) ); + if((fd = fopen(SvPVbyte_nolen(get_sv("Data::UUID::UUID_STATE_NV_STORE",0)), "wb"))) { LOCK(fd); fwrite(&(self->state), sizeof(uuid_state_t), 1, fd); UNLOCK(fd); @@ -569,7 +571,7 @@ MUTEX_UNLOCK(&instances_mutex); if (count == 0) { #endif - if ((fd = fopen(UUID_STATE_NV_STORE, "wb"))) { + if ((fd = fopen(SvPVbyte_nolen(get_sv("Data::UUID::UUID_STATE_NV_STORE",0)), "wb"))) { LOCK(fd); fwrite(&(self->state), sizeof(uuid_state_t), 1, fd); UNLOCK(fd);