Summary:
Problem: collectdctl command hangs on AIX and returns error 0 on Solaris.
Root cause - client (collectdctl) and server (collectd daemon) are using fprintf to communicate using Unix domain socket, Since fprintf buffers, command sent by client did not reach server, since client does not get the response, it closes the socket which forces the client to flush the command, now server receives the command, when responding, it gets socket error because the client already closed the socket.
Solution: Added flush after all fprintf calls.
Test Plan: Tested collectdctl on AIX and SunOS for listval, getval commands
Reviewers: skhajamo
Reviewed By: skhajamo
CC: arcyd
Differential Revision: https://all.phab.dev.bloomberg.com/
D155584
lcc_set_errno (c, errno);
return (-1);
}
+ fflush(c->fh);
return (0);
} /* }}} int lcc_send */
WARNING ("handle_flush: failed to write to socket #%i: %s", \
fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \
return -1; \
- }
+ } \
+ fflush(fh);
static int add_to_array (char ***array, int *array_num, char *value)
{
WARNING ("handle_getval: failed to write to socket #%i: %s", \
fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \
return -1; \
- }
+ } \
+ fflush(fh);
int handle_getval (FILE *fh, char *buffer)
{
WARNING ("handle_listval: failed to write to socket #%i: %s", \
fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \
free_everything_and_return (-1); \
- }
+ } \
+ fflush(fh);
int handle_listval (FILE *fh, char *buffer)
{
WARNING ("handle_putnotif: failed to write to socket #%i: %s", \
fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \
return -1; \
- }
+ } \
+ fflush(fh);
static int set_option_severity (notification_t *n, const char *value)
{
WARNING ("handle_putval: failed to write to socket #%i: %s", \
fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \
return -1; \
- }
+ } \
+ fflush(fh);
static int dispatch_values (const data_set_t *ds, value_list_t *vl,
FILE *fh, char *buffer)