notification_t n;
- memset (&n, '\0', sizeof (n));
-
name_copy = strdup (name);
if (name_copy == NULL)
{
return (-1);
}
- n.severity = NOTIF_FAILURE;
- strncpy (n.host, host, sizeof (n.host));
- n.host[sizeof (n.host) - 1] = '\0';
+ /* Copy the associative members */
+ notification_init (&n, NOTIF_FAILURE, /* host = */ NULL,
+ host, plugin, plugin_instance, type, type_instance);
sfree (name_copy);
name_copy = host = plugin = plugin_instance = type = type_instance = NULL;
pthread_mutex_lock (&cache_lock);
+ /*
+ * Set the time _after_ getting the lock because we don't know how long
+ * acquiring the lock takes and we will use this time later to decide
+ * whether or not the state is OKAY.
+ */
n.time = time (NULL);
status = c_avl_get (cache_tree, name, (void *) &ce);
notification_t n;
memset (&n, '\0', sizeof (n));
+ /* Copy the associative members */
+ NOTIFICATION_INIT_VL (&n, vl, ds);
+
n.severity = NOTIF_OKAY;
- strncpy (n.host, vl->host, sizeof (n.host));
- n.host[sizeof (n.host) - 1] = '\0';
n.time = vl->time;
snprintf (n.message, sizeof (n.message),