summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f234b32)
raw | patch | inline | side by side (parent: f234b32)
author | Florian Forster <octo@collectd.org> | |
Thu, 11 Jul 2013 11:08:11 +0000 (13:08 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 11 Jul 2013 11:16:04 +0000 (13:16 +0200) |
Profiling has shown that it is one of the bottle-necks.
src/statsd.c | patch | blob | history |
diff --git a/src/statsd.c b/src/statsd.c
index a83cc9a2ece6907c9f2009286f04e3e5259b920e..364b97d7c5838cd4625d55065054f25fe3d2c73f 100644 (file)
--- a/src/statsd.c
+++ b/src/statsd.c
static void statsd_parse_buffer (char *buffer) /* {{{ */
{
- char *dummy;
- char *saveptr = NULL;
- char *ptr;
-
- for (dummy = buffer;
- (ptr = strtok_r (dummy, "\r\n", &saveptr)) != NULL;
- dummy = NULL)
+ while (buffer != NULL)
{
- char *line_orig = sstrdup (ptr);
+ char orig[64];
+ char *next;
int status;
- status = statsd_parse_line (ptr);
+ next = strchr (buffer, '\n');
+ if (next != NULL)
+ {
+ *next = 0;
+ next++;
+ }
+
+ if (*buffer == 0)
+ {
+ buffer = next;
+ continue;
+ }
+
+ sstrncpy (orig, buffer, sizeof (orig));
+
+ status = statsd_parse_line (buffer);
if (status != 0)
- ERROR ("statsd plugin: Unable to parse line: \"%s\"", line_orig);
+ ERROR ("statsd plugin: Unable to parse line: \"%s\"", orig);
- sfree (line_orig);
+ buffer = next;
}
} /* }}} void statsd_parse_buffer */