projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
799ef5d
)
perl plugin: Added call_pv_locked() wrapper to handle thread locking flags.
author
Pavel Rochnyack
<pavel2000@ngs.ru>
Mon, 30 May 2016 05:52:21 +0000
(11:52 +0600)
committer
Sebastian Harl
<sh@tokkee.org>
Mon, 30 May 2016 19:51:36 +0000
(21:51 +0200)
src/perl.c
patch
|
blob
|
history
diff --git
a/src/perl.c
b/src/perl.c
index
d253d09
..
434e808
100644
(file)
--- a/
src/perl.c
+++ b/
src/perl.c
@@
-992,30
+992,43
@@
static int pplugin_dispatch_notification (pTHX_ HV *notif)
} /* static int pplugin_dispatch_notification (HV *) */
/*
} /* static int pplugin_dispatch_notification (HV *) */
/*
- * Call
all working functions of the given type
.
+ * Call
perl sub with thread locking flags handled
.
*/
*/
-static int
pplugin_call_all (pTHX_ int type, ...
)
+static int
call_pv_locked (pTHX_ const char* sub_name
)
{
{
- int retvals = 0;
-
_Bool old_running;
_Bool old_running;
- va_list ap;
- int ret = 0;
-
- dSP;
+ int ret;
c_ithread_t *t = (c_ithread_t *)pthread_getspecific(perl_thr_key);
c_ithread_t *t = (c_ithread_t *)pthread_getspecific(perl_thr_key);
- if (t == NULL) /* thread destroyed
( c_ithread_destroy*() -> log_debug() )
*/
+ if (t == NULL) /* thread destroyed */
return 0;
old_running = t->running;
t->running = 1;
return 0;
old_running = t->running;
t->running = 1;
-
+
if (t->shutdown) {
t->running = old_running;
return 0;
}
if (t->shutdown) {
t->running = old_running;
return 0;
}
+ ret = call_pv (sub_name, G_SCALAR);
+
+ t->running = old_running;
+ return ret;
+} /* static int call_pv_locked (pTHX, *sub_name) */
+
+/*
+ * Call all working functions of the given type.
+ */
+static int pplugin_call_all (pTHX_ int type, ...)
+{
+ int retvals = 0;
+
+ va_list ap;
+ int ret = 0;
+
+ dSP;
+
if ((type < 0) || (type >= PLUGIN_TYPES))
return -1;
if ((type < 0) || (type >= PLUGIN_TYPES))
return -1;
@@
-1129,7
+1142,7
@@
static int pplugin_call_all (pTHX_ int type, ...)
PUTBACK;
PUTBACK;
- retvals = call_pv
("Collectd::plugin_call_all", G_SCALAR
);
+ retvals = call_pv
_locked (aTHX_ "Collectd::plugin_call_all"
);
SPAGAIN;
if (0 < retvals) {
SPAGAIN;
if (0 < retvals) {
@@
-1142,7
+1155,6
@@
static int pplugin_call_all (pTHX_ int type, ...)
FREETMPS;
LEAVE;
FREETMPS;
LEAVE;
- t->running = old_running;
va_end (ap);
return ret;
} /* static int pplugin_call_all (int, ...) */
va_end (ap);
return ret;
} /* static int pplugin_call_all (int, ...) */
@@
-1265,7
+1277,6
@@
static int fc_call (pTHX_ int type, int cb_type, pfc_user_data_t *data, ...)
{
int retvals = 0;
{
int retvals = 0;
- _Bool old_running;
va_list ap;
int ret = 0;
va_list ap;
int ret = 0;
@@
-1274,18
+1285,6
@@
static int fc_call (pTHX_ int type, int cb_type, pfc_user_data_t *data, ...)
dSP;
dSP;
- c_ithread_t *t = (c_ithread_t *)pthread_getspecific(perl_thr_key);
- if (t == NULL) /* thread destroyed */
- return 0;
-
- old_running = t->running;
- t->running = 1;
-
- if (t->shutdown) {
- t->running = old_running;
- return 0;
- }
-
if ((type < 0) || (type >= FC_TYPES))
return -1;
if ((type < 0) || (type >= FC_TYPES))
return -1;
@@
-1384,7
+1383,7
@@
static int fc_call (pTHX_ int type, int cb_type, pfc_user_data_t *data, ...)
PUTBACK;
PUTBACK;
- retvals = call_pv
("Collectd::fc_call", G_SCALAR
);
+ retvals = call_pv
_locked (aTHX_ "Collectd::fc_call"
);
if ((FC_CB_EXEC == cb_type) && (meta != NULL)) {
assert (pmeta != NULL);
if ((FC_CB_EXEC == cb_type) && (meta != NULL)) {
assert (pmeta != NULL);
@@
-1409,7
+1408,6
@@
static int fc_call (pTHX_ int type, int cb_type, pfc_user_data_t *data, ...)
FREETMPS;
LEAVE;
FREETMPS;
LEAVE;
- t->running = old_running;
va_end (ap);
return ret;
} /* static int fc_call (int, int, pfc_user_data_t *, ...) */
va_end (ap);
return ret;
} /* static int fc_call (int, int, pfc_user_data_t *, ...) */