diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-10-26 13:03:01 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-10-26 13:03:01 +0000 |
commit | df3728a2a53a64c63edf08a4429a7a57b76ca4aa (patch) | |
tree | 41cb3c77a25414e4bf6259507dfbadcbc2ea463d /ext/ODBM_File | |
parent | 9ece3ee6650e9c2f6d5131c19ae5e80f2a8bfc4a (diff) | |
download | perl-df3728a2a53a64c63edf08a4429a7a57b76ca4aa.tar.gz |
Integrate maintperl changes #12268 and #12669;
final touches to the audit for statics and thread-unsafe code
* make DB_File, ODBM_File thread-safe
* remove unnecessary/dangerous statics and protect others
from not getting accidentally enabled under threaded perls
windows support functions get_childdir() et al aren't exported
correctly under vanilla build
Testing under win32 appreciated since changes there had
to be manually merged and I cannot test how badly did I do.
p4raw-link: @12268 on //depot/perlio: bb407f0b8769c638c05e60ebfd157a1e676a6c22
p4raw-id: //depot/perl@12678
p4raw-integrated: from //depot/maint-5.6/perl@12677 'copy in'
win32/vmem.h (@5902..) 'merge in' ext/DB_File/DB_File.xs
(@8693..) win32/win32iop.h (@8917..) ext/ODBM_File/ODBM_File.xs
(@8995..) iperlsys.h (@9154..) scope.c (@9584..) makedef.pl
(@11425..) gv.c (@12026..) op.c (@12145..) util.c (@12220..)
toke.c (@12550..) ext/B/B.xs ext/File/Glob/Glob.xs
ext/Opcode/Opcode.xs ext/re/re.xs (@12653..) mg.c win32/win32.c
(@12668..)
Diffstat (limited to 'ext/ODBM_File')
-rw-r--r-- | ext/ODBM_File/ODBM_File.xs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ext/ODBM_File/ODBM_File.xs b/ext/ODBM_File/ODBM_File.xs index 5a556bfd2f..3bc94fe073 100644 --- a/ext/ODBM_File/ODBM_File.xs +++ b/ext/ODBM_File/ODBM_File.xs @@ -81,7 +81,15 @@ typedef datum datum_value ; #define odbm_FIRSTKEY(db) firstkey() #define odbm_NEXTKEY(db,key) nextkey(key) -static int dbmrefcnt; +#define MY_CXT_KEY "ODBM_File::_guts" XS_VERSION + +typedef struct { + int x_dbmrefcnt; +} my_cxt_t; + +START_MY_CXT + +#define dbmrefcnt (MY_CXT.x_dbmrefcnt) #ifndef DBM_REPLACE #define DBM_REPLACE 0 @@ -89,6 +97,11 @@ static int dbmrefcnt; MODULE = ODBM_File PACKAGE = ODBM_File PREFIX = odbm_ +BOOT: +{ + MY_CXT_INIT; +} + ODBM_File odbm_TIEHASH(dbtype, filename, flags, mode) char * dbtype @@ -99,6 +112,8 @@ odbm_TIEHASH(dbtype, filename, flags, mode) { char *tmpbuf; void * dbp ; + dMY_CXT; + if (dbmrefcnt++) croak("Old dbm can only open one database"); New(0, tmpbuf, strlen(filename) + 5, char); @@ -126,6 +141,8 @@ odbm_TIEHASH(dbtype, filename, flags, mode) void DESTROY(db) ODBM_File db + PREINIT: + dMY_CXT; CODE: dbmrefcnt--; dbmclose(); |