From 0ea11b520f610d0ed8fc34f50a7880c3c78c4186 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 17 Dec 2015 14:21:27 +0100 Subject: [PATCH] gmond plugin: Check return value of setsockopt(2). CID: 38112 --- src/gmond.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gmond.c b/src/gmond.c index a1fa9ea4..99d1334b 100644 --- a/src/gmond.c +++ b/src/gmond.c @@ -286,8 +286,14 @@ static int create_sockets (socket_entry_t **ret_sockets, /* {{{ */ { int yes = 1; - setsockopt (sockets[sockets_num].fd, SOL_SOCKET, SO_REUSEADDR, + status = setsockopt (sockets[sockets_num].fd, SOL_SOCKET, SO_REUSEADDR, (void *) &yes, sizeof (yes)); + if (status != 0) + { + char errbuf[1024]; + WARNING ("gmond plugin: setsockopt(2) failed: %s", + sstrerror (errno, errbuf, sizeof (errbuf))); + } } status = bind (sockets[sockets_num].fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen); -- 2.30.2