summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorDrago Goricanec <drago@raptor.otsd.ts.fujitsu.co.jp>1998-09-25 07:01:09 +0900
committerGurusamy Sarathy <gsar@cpan.org>1998-09-25 01:19:38 +0000
commit333f433b6bc052819c91a73e390fb65b29161409 (patch)
tree52862521bdccb3debbcb553e714e2ddd18a1502a /hv.c
parent942e002ed0b680ac66fb5ed33d36b864f6c264af (diff)
downloadperl-333f433b6bc052819c91a73e390fb65b29161409.tar.gz
lock sv_mutex in new_he() and del_he() for USE_THREADS
Message-Id: <19980924220109J.drago@otsd.ts.fujitsu.co.jp> Subject: [PATCH 5.005_51] Re: Perl 5.005_51 not yet multi Thread safe p4raw-id: //depot/perl@1880
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/hv.c b/hv.c
index 2416831256..ddd989fa23 100644
--- a/hv.c
+++ b/hv.c
@@ -18,7 +18,7 @@ static void hv_magic_check _((HV *hv, bool *needs_copy, bool *needs_store));
#ifndef PERL_OBJECT
static void hsplit _((HV *hv));
static void hfreeentries _((HV *hv));
-static HE* more_he _((void));
+static void more_he _((void));
#endif
#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
@@ -32,22 +32,25 @@ STATIC HE*
new_he(void)
{
HE* he;
- if (PL_he_root) {
- he = PL_he_root;
- PL_he_root = HeNEXT(he);
- return he;
- }
- return more_he();
+ LOCK_SV_MUTEX;
+ if (!PL_he_root)
+ more_he();
+ he = PL_he_root;
+ PL_he_root = HeNEXT(he);
+ UNLOCK_SV_MUTEX;
+ return he;
}
STATIC void
del_he(HE *p)
{
+ LOCK_SV_MUTEX;
HeNEXT(p) = (HE*)PL_he_root;
PL_he_root = p;
+ UNLOCK_SV_MUTEX;
}
-STATIC HE*
+STATIC void
more_he(void)
{
register HE* he;
@@ -60,7 +63,6 @@ more_he(void)
he++;
}
HeNEXT(he) = 0;
- return new_he();
}
STATIC HEK *
@@ -1167,9 +1169,9 @@ unsharepvn(char *str, I32 len, U32 hash)
del_he(entry);
--xhv->xhv_keys;
}
- UNLOCK_STRTAB_MUTEX;
break;
}
+ UNLOCK_STRTAB_MUTEX;
if (!found)
warn("Attempt to free non-existent shared string");