From: Florian Forster Date: Thu, 17 Dec 2015 13:18:59 +0000 (+0100) Subject: gmond plugin: Check return value of sendto(2). X-Git-Tag: collectd-5.5.1~12^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1c639d74e12ae6da05f93596478429c389246b4e;p=collectd.git gmond plugin: Check return value of sendto(2). CID: 38113 --- 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);