[collectd] [PATCH] perl plugin: Added debugging output to display the ithread behavior.

Sebastian Harl sh at tokkee.org
Wed Nov 14 14:19:42 CET 2007


Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
 src/perl.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/perl.c b/src/perl.c
index 889ab56..fbbe591 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -91,6 +91,11 @@ typedef struct {
 	c_ithread_t *head;
 	c_ithread_t *tail;
 
+#if COLLECT_DEBUG
+	/* some usage stats */
+	int number_of_threads;
+#endif /* COLLECT_DEBUG */
+
 	pthread_mutex_t mutex;
 } c_ithread_list_t;
 
@@ -749,6 +754,10 @@ static c_ithread_t *c_ithread_create (PerlInterpreter *base)
 		? NULL
 		: perl_clone (base, CLONEf_KEEP_PTR_TABLE);
 
+#if COLLECT_DEBUG
+	++perl_threads->number_of_threads;
+#endif /* COLLECT_DEBUG */
+
 	t->next = NULL;
 
 	if (NULL == perl_threads->tail) {
@@ -784,6 +793,9 @@ static int perl_init (void)
 
 		aTHX = t->interp;
 	}
+
+	log_debug ("perl_init: c_ithread: interp = %p (active threads: %i)\n",
+			aTHX, perl_threads->number_of_threads);
 	return pplugin_call_all (aTHX_ PLUGIN_INIT);
 } /* static int perl_init (void) */
 
@@ -803,6 +815,9 @@ static int perl_read (void)
 
 		aTHX = t->interp;
 	}
+
+	log_debug ("perl_read: c_ithread: interp = %p (active threads: %i)\n",
+			aTHX, perl_threads->number_of_threads);
 	return pplugin_call_all (aTHX_ PLUGIN_READ);
 } /* static int perl_read (void) */
 
@@ -822,6 +837,9 @@ static int perl_write (const data_set_t *ds, const value_list_t *vl)
 
 		aTHX = t->interp;
 	}
+
+	log_debug ("perl_write: c_ithread: interp = %p (active threads: %i)\n",
+			aTHX, perl_threads->number_of_threads);
 	return pplugin_call_all (aTHX_ PLUGIN_WRITE, ds, vl);
 } /* static int perl_write (const data_set_t *, const value_list_t *) */
 
@@ -869,6 +887,9 @@ static int perl_shutdown (void)
 		aTHX = t->interp;
 	}
 
+	log_debug ("perl_shutdown: c_ithread: interp = %p (active threads: %i)\n",
+			aTHX, perl_threads->number_of_threads);
+
 	plugin_unregister_log ("perl");
 	plugin_unregister_init ("perl");
 	plugin_unregister_read ("perl");
-- 
1.5.3.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20071114/1057a233/attachment.pgp 


More information about the collectd mailing list