summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3ac843c)
raw | patch | inline | side by side (parent: 3ac843c)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 1 May 2008 23:14:32 +0000 (01:14 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 6 May 2008 12:23:55 +0000 (14:23 +0200) |
Full-duplex standard I/O streams are not really supported on sockets.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/collectd-nagios.c | patch | blob | history |
diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c
index 63effd5528bd706a30426d0b22cb557fd91faee9..f4dff5bb99a5efeb64d2a48f314c18e458848e03 100644 (file)
--- a/src/collectd-nagios.c
+++ b/src/collectd-nagios.c
struct sockaddr_un sa;
int status;
int fd;
- FILE *fh;
+ FILE *fh_in, *fh_out;
char buffer[4096];
int values_num;
return (-1);
}
- fh = fdopen (fd, "r+");
- if (fh == NULL)
+ fh_in = fdopen (fd, "r");
+ if (fh_in == NULL)
{
fprintf (stderr, "fdopen failed: %s\n",
strerror (errno));
return (-1);
}
- fprintf (fh, "GETVAL %s/%s\n", hostname_g, value_string_g);
- fflush (fh);
+ fh_out = fdopen (fd, "w");
+ if (fh_out == NULL)
+ {
+ fprintf (stderr, "fdopen failed: %s\n",
+ strerror (errno));
+ fclose (fh_in);
+ return (-1);
+ }
+
+ fprintf (fh_out, "GETVAL %s/%s\n", hostname_g, value_string_g);
+ fflush (fh_out);
- if (fgets (buffer, sizeof (buffer), fh) == NULL)
+ if (fgets (buffer, sizeof (buffer), fh_in) == NULL)
{
fprintf (stderr, "fgets failed: %s\n",
strerror (errno));
- close (fd);
+ fclose (fh_in);
+ fclose (fh_out);
return (-1);
}
- close (fd); fd = -1;
+ fclose (fh_in); fh_in = NULL; fd = -1;
+ fclose (fh_out); fh_out = NULL;
values_num = atoi (buffer);
if (values_num < 1)