oconfig: fix oconfig_free to free all elements
[collectd.git] / src / rrdcached.c
index cf23803..e77be2d 100644 (file)
@@ -46,7 +46,9 @@ static rrdcreate_config_t rrdcreate_config =
        /* timespans_num = */ 0,
 
        /* consolidation_functions = */ NULL,
-       /* consolidation_functions_num = */ 0
+       /* consolidation_functions_num = */ 0,
+
+       /* async = */ 0
 };
 
 /*
@@ -119,6 +121,21 @@ static int value_list_to_filename (char *buffer, size_t buffer_size,
   int status;
   size_t len;
 
+  if (datadir != NULL)
+  {
+    size_t datadir_len = strlen (datadir) + 1;
+
+    if (datadir_len >= buffer_size)
+      return (ENOMEM);
+
+    sstrncpy (buffer, datadir, buffer_size);
+    buffer[datadir_len - 1] = '/';
+    buffer[datadir_len] = 0;
+
+    buffer += datadir_len;
+    buffer_size -= datadir_len;
+  }
+
   status = FORMAT_VL (buffer, buffer_size, vl);
   if (status != 0)
     return (status);
@@ -224,6 +241,8 @@ static int rc_config (oconfig_item_t *ci)
       status = cf_util_get_string (child, &daemon_address);
     else if (strcasecmp ("CreateFiles", key) == 0)
       status = cf_util_get_boolean (child, &config_create_files);
+    else if (strcasecmp ("CreateFilesAsync", key) == 0)
+      status = cf_util_get_boolean (child, &rrdcreate_config.async);
     else if (strcasecmp ("CollectStatistics", key) == 0)
       status = cf_util_get_boolean (child, &config_collect_stats);
     else if (strcasecmp ("StepSize", key) == 0)
@@ -441,6 +460,8 @@ static int rc_write (const data_set_t *ds, const value_list_t *vl,
             filename);
         return (-1);
       }
+      else if (rrdcreate_config.async)
+        return (0);
     }
   }