Removed the config-option `LoadDS' and the passing of the `modreg_e' enum to `module_...
[collectd.git] / src / email.c
index eed91f1..b476755 100644 (file)
@@ -137,36 +137,6 @@ static const char *config_keys[] =
 };
 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
 
-static data_source_t gauge_dsrc[1] =
-{
-       {"value", DS_TYPE_GAUGE, 0.0, NAN}
-};
-
-static data_set_t email_count_ds =
-{
-       "email_count", 1, gauge_dsrc
-};
-
-static data_set_t email_size_ds =
-{
-       "email_size", 1, gauge_dsrc
-};
-
-static data_set_t spam_check_ds =
-{
-       "spam_check", 1, gauge_dsrc
-};
-
-static data_source_t spam_score_dsrc[1] =
-{
-       {"score", DS_TYPE_GAUGE, NAN, NAN}
-};
-
-static data_set_t spam_score_ds =
-{
-       "spam_score", 1, spam_score_dsrc
-};
-
 /* socket configuration */
 static char *sock_group = COLLECTD_GRP_NAME;
 static int  sock_perms  = S_IRWXU | S_IRWXG;
@@ -190,7 +160,7 @@ static conn_list_t conns;
 static pthread_cond_t collector_available = PTHREAD_COND_INITIALIZER;
 
 /* collector threads */
-static collector_t **collectors;
+static collector_t **collectors = NULL;
 
 static pthread_mutex_t available_mutex = PTHREAD_MUTEX_INITIALIZER;
 static int available_collectors;
@@ -724,9 +694,6 @@ static int email_shutdown (void)
 {
        int i = 0;
 
-       if (disabled)
-               return (0);
-
        if (connector != ((pthread_t) 0)) {
                pthread_kill (connector, SIGTERM);
                connector = (pthread_t) 0;
@@ -740,21 +707,27 @@ static int email_shutdown (void)
        /* don't allow any more connections to be processed */
        pthread_mutex_lock (&conns_mutex);
 
-       for (i = 0; i < max_conns; ++i) {
-               if (collectors[i]->thread != ((pthread_t) 0)) {
-                       pthread_kill (collectors[i]->thread, SIGTERM);
-                       collectors[i]->thread = (pthread_t) 0;
-               }
-               
-               if (collectors[i]->socket >= 0) {
-                       close (collectors[i]->socket);
-                       collectors[i]->socket = -1;
+       if (collectors != NULL) {
+               for (i = 0; i < max_conns; ++i) {
+                       if (collectors[i] == NULL)
+                               continue;
+
+                       if (collectors[i]->thread != ((pthread_t) 0)) {
+                               pthread_kill (collectors[i]->thread, SIGTERM);
+                               collectors[i]->thread = (pthread_t) 0;
+                       }
+
+                       if (collectors[i]->socket >= 0) {
+                               close (collectors[i]->socket);
+                               collectors[i]->socket = -1;
+                       }
                }
-       }
+       } /* if (collectors != NULL) */
 
        pthread_mutex_unlock (&conns_mutex);
 
        unlink (SOCK_PATH);
+       errno = 0;
 
        return (0);
 } /* static void email_shutdown (void) */
@@ -888,22 +861,11 @@ static int email_read (void)
        return (0);
 } /* int email_read */
 
-void module_register (modreg_e load)
+void module_register (void)
 {
-       if (load & MR_DATASETS)
-       {
-               plugin_register_data_set (&email_count_ds);
-               plugin_register_data_set (&email_size_ds);
-               plugin_register_data_set (&spam_check_ds);
-               plugin_register_data_set (&spam_score_ds);
-       }
-
-       if (load & MR_READ)
-       {
-               plugin_register_config ("email", email_config, config_keys, config_keys_num);
-               plugin_register_init ("email", email_init);
-               plugin_register_read ("email", email_read);
-       }
+       plugin_register_config ("email", email_config, config_keys, config_keys_num);
+       plugin_register_init ("email", email_init);
+       plugin_register_read ("email", email_read);
        plugin_register_shutdown ("email", email_shutdown);
 } /* void module_register */