From 1c639d74e12ae6da05f93596478429c389246b4e Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 17 Dec 2015 14:18:59 +0100 Subject: [PATCH] gmond plugin: Check return value of sendto(2). CID: 38113 --- src/gmond.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gmond.c b/src/gmond.c index 99d1334b..629a9ad2 100644 --- a/src/gmond.c +++ b/src/gmond.c @@ -411,10 +411,19 @@ static int request_meta_data (const char *host, const char *name) /* {{{ */ pthread_mutex_lock (&mc_send_sockets_lock); for (i = 0; i < mc_send_sockets_num; i++) - sendto (mc_send_sockets[i].fd, buffer, (size_t) buffer_size, + { + ssize_t status = sendto (mc_send_sockets[i].fd, buffer, (size_t) buffer_size, /* flags = */ 0, (struct sockaddr *) &mc_send_sockets[i].addr, mc_send_sockets[i].addrlen); + if (status == -1) + { + char errbuf[1024]; + ERROR ("gmond plugin: sendto(2) failed: %s", + sstrerror (errno, errbuf, sizeof (errbuf))); + continue; + } + } pthread_mutex_unlock (&mc_send_sockets_lock); sfree (msg.Ganglia_metadata_msg_u.grequest.metric_id.host); -- 2.30.2