projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
utils_vl_lookup: Fixed a race when creating user objects.
[collectd.git]
/
src
/
utils_tail.c
diff --git
a/src/utils_tail.c
b/src/utils_tail.c
index
eaf8f73
..
0b31262
100644
(file)
--- a/
src/utils_tail.c
+++ b/
src/utils_tail.c
@@
-162,6
+162,7
@@
int cu_tail_readline (cu_tail_t *obj, char *buf, int buflen)
/* Try to read from the filehandle. If that succeeds, everything appears to
* be fine and we can return. */
/* Try to read from the filehandle. If that succeeds, everything appears to
* be fine and we can return. */
+ clearerr (obj->fh);
if (fgets (buf, buflen, obj->fh) != NULL)
{
buf[buflen - 1] = 0;
if (fgets (buf, buflen, obj->fh) != NULL)
{
buf[buflen - 1] = 0;
@@
-219,6
+220,8
@@
int cu_tail_read (cu_tail_t *obj, char *buf, int buflen, tailfunc_t *callback,
while (42)
{
while (42)
{
+ size_t len;
+
status = cu_tail_readline (obj, buf, buflen);
if (status != 0)
{
status = cu_tail_readline (obj, buf, buflen);
if (status != 0)
{
@@
-231,6
+234,14
@@
int cu_tail_read (cu_tail_t *obj, char *buf, int buflen, tailfunc_t *callback,
if (buf[0] == 0)
break;
if (buf[0] == 0)
break;
+ len = strlen (buf);
+ while (len > 0) {
+ if (buf[len - 1] != '\n')
+ break;
+ buf[len - 1] = '\0';
+ len--;
+ }
+
status = callback (data, buf, buflen);
if (status != 0)
{
status = callback (data, buf, buflen);
if (status != 0)
{