projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-4.3' into collectd-4.4
[collectd.git]
/
src
/
network.c
diff --git
a/src/network.c
b/src/network.c
index
e150364
..
0f558ca
100644
(file)
--- a/
src/network.c
+++ b/
src/network.c
@@
-183,7
+183,7
@@
static pthread_mutex_t send_buffer_lock = PTHREAD_MUTEX_INITIALIZER;
static c_avl_tree_t *cache_tree = NULL;
static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER;
static c_avl_tree_t *cache_tree = NULL;
static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER;
-static time_t cache_flush_last;
+static time_t cache_flush_last
= 0
;
static int cache_flush_interval = 1800;
/*
static int cache_flush_interval = 1800;
/*
@@
-1405,7
+1405,7
@@
static int add_to_buffer (char *buffer, int buffer_size,
if (write_part_string (&buffer, &buffer_size, TYPE_HOST,
vl->host, strlen (vl->host)) != 0)
return (-1);
if (write_part_string (&buffer, &buffer_size, TYPE_HOST,
vl->host, strlen (vl->host)) != 0)
return (-1);
- s
trcpy (vl_def->host, vl->host
);
+ s
strncpy (vl_def->host, vl->host, sizeof (vl_def->host)
);
}
if (vl_def->time != vl->time)
}
if (vl_def->time != vl->time)
@@
-1429,7
+1429,7
@@
static int add_to_buffer (char *buffer, int buffer_size,
if (write_part_string (&buffer, &buffer_size, TYPE_PLUGIN,
vl->plugin, strlen (vl->plugin)) != 0)
return (-1);
if (write_part_string (&buffer, &buffer_size, TYPE_PLUGIN,
vl->plugin, strlen (vl->plugin)) != 0)
return (-1);
- s
trcpy (vl_def->plugin, vl->plugin
);
+ s
strncpy (vl_def->plugin, vl->plugin, sizeof (vl_def->plugin)
);
}
if (strcmp (vl_def->plugin_instance, vl->plugin_instance) != 0)
}
if (strcmp (vl_def->plugin_instance, vl->plugin_instance) != 0)
@@
-1438,7
+1438,7
@@
static int add_to_buffer (char *buffer, int buffer_size,
vl->plugin_instance,
strlen (vl->plugin_instance)) != 0)
return (-1);
vl->plugin_instance,
strlen (vl->plugin_instance)) != 0)
return (-1);
- s
trcpy (vl_def->plugin_instance, vl->plugin_instance
);
+ s
strncpy (vl_def->plugin_instance, vl->plugin_instance, sizeof (vl_def->plugin_instance)
);
}
if (strcmp (type_def, ds->type) != 0)
}
if (strcmp (type_def, ds->type) != 0)
@@
-1446,7
+1446,7
@@
static int add_to_buffer (char *buffer, int buffer_size,
if (write_part_string (&buffer, &buffer_size, TYPE_TYPE,
ds->type, strlen (ds->type)) != 0)
return (-1);
if (write_part_string (&buffer, &buffer_size, TYPE_TYPE,
ds->type, strlen (ds->type)) != 0)
return (-1);
- s
trcpy (type_def, ds->type
);
+ s
strncpy (type_def, ds->type, sizeof (type_def)
);
}
if (strcmp (vl_def->type_instance, vl->type_instance) != 0)
}
if (strcmp (vl_def->type_instance, vl->type_instance) != 0)
@@
-1455,7
+1455,7
@@
static int add_to_buffer (char *buffer, int buffer_size,
vl->type_instance,
strlen (vl->type_instance)) != 0)
return (-1);
vl->type_instance,
strlen (vl->type_instance)) != 0)
return (-1);
- s
trcpy (vl_def->type_instance, vl->type_instance
);
+ s
strncpy (vl_def->type_instance, vl->type_instance, sizeof (vl_def->type_instance)
);
}
if (write_part_values (&buffer, &buffer_size, ds, vl) != 0)
}
if (write_part_values (&buffer, &buffer_size, ds, vl) != 0)
@@
-1706,11
+1706,19
@@
static int network_shutdown (void)
plugin_unregister_write ("network");
plugin_unregister_shutdown ("network");
plugin_unregister_write ("network");
plugin_unregister_shutdown ("network");
+ /* Let the init function do it's move again ;) */
+ cache_flush_last = 0;
+
return (0);
} /* int network_shutdown */
static int network_init (void)
{
return (0);
} /* int network_shutdown */
static int network_init (void)
{
+ /* Check if we were already initialized. If so, just return - there's
+ * nothing more to do (for now, that is). */
+ if (cache_flush_last != 0)
+ return (0);
+
plugin_register_shutdown ("network", network_shutdown);
send_buffer_ptr = send_buffer;
plugin_register_shutdown ("network", network_shutdown);
send_buffer_ptr = send_buffer;