#include <arpa/inet.h> /* ntohs/ntohl */
#endif
+/* AIX doesn't have MSG_DONTWAIT */
+#ifndef MSG_DONTWAIT
+#define MSG_DONTWAIT MSG_NONBLOCK
+#endif
+
#define CONFIG_KEY_HOST "Host"
#define CONFIG_KEY_PORT "Port"
#define CONFIG_KEY_TIMEOUT "Timeout"
}
}
+static void chrony_flush_recv_queue(void) {
+ char buf[1];
+
+ if (g_chrony_is_connected) {
+ while (recv(g_chrony_socket, buf, sizeof(buf), MSG_DONTWAIT) > 0)
+ ;
+ }
+}
+
static int chrony_query(const int p_command, tChrony_Request *p_req,
tChrony_Response *p_resp, size_t *p_resp_size) {
/* Check connection. We simply perform one try as collectd already handles
g_chrony_seq_is_initialized = 1;
}
+ /* Ignore late responses that may have been received */
+ chrony_flush_recv_queue();
+
/* Get daemon stats */
rc = chrony_request_daemon_stats();
if (rc != CHRONY_RC_OK)