From fba3b22e783d72569126ff6fe76f3cb6cd1f043b Mon Sep 17 00:00:00 2001 From: Malcolm Beattie Date: Fri, 3 Oct 1997 15:17:39 +0000 Subject: Fixed sv_mutex locking for new_SV, del_SV and nice_chunks. p4raw-id: //depot/perl@103 --- sv.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'sv.c') diff --git a/sv.c b/sv.c index bdc3c71ed5..e4214c6b8d 100644 --- a/sv.c +++ b/sv.c @@ -65,14 +65,18 @@ typedef void (*SVFUNC) _((SV*)); #define new_SV(p) \ do { \ + MUTEX_LOCK(&sv_mutex); \ (p) = (SV*)safemalloc(sizeof(SV)); \ reg_add(p); \ + MUTEX_UNLOCK(&sv_mutex); \ } while (0) #define del_SV(p) \ do { \ + MUTEX_LOCK(&sv_mutex); \ reg_remove(p); \ free((char*)(p)); \ + MUTEX_UNLOCK(&sv_mutex); \ } while (0) static SV **registry; @@ -171,28 +175,33 @@ U32 flags; --sv_count; \ } while (0) +/* sv_mutex must be held while calling uproot_SV() */ #define uproot_SV(p) \ do { \ - MUTEX_LOCK(&sv_mutex); \ (p) = sv_root; \ sv_root = (SV*)SvANY(p); \ ++sv_count; \ - MUTEX_UNLOCK(&sv_mutex); \ } while (0) -#define new_SV(p) \ - if (sv_root) \ - uproot_SV(p); \ - else \ - (p) = more_sv() +#define new_SV(p) do { \ + MUTEX_LOCK(&sv_mutex); \ + if (sv_root) \ + uproot_SV(p); \ + else \ + (p) = more_sv(); \ + MUTEX_UNLOCK(&sv_mutex); \ + } while (0) #ifdef DEBUGGING -#define del_SV(p) \ - if (debug & 32768) \ - del_sv(p); \ - else \ - plant_SV(p) +#define del_SV(p) do { \ + MUTEX_LOCK(&sv_mutex); \ + if (debug & 32768) \ + del_sv(p); \ + else \ + plant_SV(p); \ + MUTEX_UNLOCK(&sv_mutex); \ + } while (0) static void del_sv(p) @@ -253,6 +262,7 @@ U32 flags; SvFLAGS(sv) = SVTYPEMASK; } +/* sv_mutex must be held while calling more_sv() */ static SV* more_sv() { -- cgit v1.2.1