summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Bergman <sky@nanisky.com>2001-08-17 12:28:41 +0000
committerArtur Bergman <sky@nanisky.com>2001-08-17 12:28:41 +0000
commit667883b043ec7c3a2eb983d65a38f863f9a39fbd (patch)
treeed4b494f6ee4344790fb20d34e38e5ce6797e69a
parent1dca008a36fa9607cc704328e383316f3c7223e2 (diff)
downloadperl-667883b043ec7c3a2eb983d65a38f863f9a39fbd.tar.gz
Protext sharedsv_space better. Extended EDIT and RELEASE macro
p4raw-id: //depot/perl@11707
-rw-r--r--sharedsv.c8
-rw-r--r--sharedsv.h11
2 files changed, 13 insertions, 6 deletions
diff --git a/sharedsv.c b/sharedsv.c
index 43596941de..1703257cf2 100644
--- a/sharedsv.c
+++ b/sharedsv.c
@@ -21,6 +21,7 @@
#include "perl.h"
PerlInterpreter* sharedsv_space;
+perl_mutex sharedsv_space_mutex;
#ifdef USE_ITHREADS
@@ -45,6 +46,7 @@ void
Perl_sharedsv_init(pTHX)
{
sharedsv_space = PERL_GET_CONTEXT;
+ MUTEX_INIT(&sharedsv_space_mutex);
}
/*
@@ -145,9 +147,9 @@ Increments the threadcount of a sharedsv.
void
Perl_sharedsv_thrcnt_inc(pTHX_ shared_sv* ssv)
{
- SHAREDSvLOCK(ssv);
+ SHAREDSvEDIT(ssv);
SvREFCNT_inc(ssv->sv);
- SHAREDSvUNLOCK(ssv);
+ SHAREDSvRELEASE(ssv);
}
/*
@@ -163,7 +165,6 @@ void
Perl_sharedsv_thrcnt_dec(pTHX_ shared_sv* ssv)
{
SV* sv;
- SHAREDSvLOCK(ssv);
SHAREDSvEDIT(ssv);
sv = SHAREDSvGET(ssv);
if (SvREFCNT(sv) == 1) {
@@ -195,7 +196,6 @@ Perl_sharedsv_thrcnt_dec(pTHX_ shared_sv* ssv)
}
SvREFCNT_dec(sv);
SHAREDSvRELEASE(ssv);
- SHAREDSvUNLOCK(ssv);
}
#endif
diff --git a/sharedsv.h b/sharedsv.h
index 16bba11841..1dec85461b 100644
--- a/sharedsv.h
+++ b/sharedsv.h
@@ -10,6 +10,7 @@ typedef struct {
} shared_sv;
extern PerlInterpreter* sharedsv_space;
+extern perl_mutex sharedsv_space_mutex;
void Perl_sharedsv_unlock_scope(pTHX_ shared_sv* ssv);
void Perl_sharedsv_unlock(pTHX_ shared_sv* ssv);
@@ -22,8 +23,14 @@ void Perl_sharedsv_thrcnt_dec(pTHX_ shared_sv* ssv);
#define SHAREDSvGET(a) (a->sv)
-#define SHAREDSvEDIT(a) PERL_SET_CONTEXT(sharedsv_space)
-#define SHAREDSvRELEASE(a) PERL_SET_CONTEXT(my_perl)
+#define SHAREDSvEDIT(a) { MUTEX_LOCK(&sharedsv_space_mutex);\
+SHAREDSvLOCK((a));\
+PERL_SET_CONTEXT(sharedsv_space);\
+}
+#define SHAREDSvRELEASE(a) { PERL_SET_CONTEXT((a)->owner);\
+SHAREDSvUNLOCK((a));\
+MUTEX_UNLOCK(&sharedsv_space_mutex);\
+}
#define SHAREDSvLOCK(a) Perl_sharedsv_lock(aTHX_ a)
#define SHAREDSvUNLOCK(a) Perl_sharedsv_unlock(aTHX_ a)