@cryptotaxi247 / netdata-1 / commits / 59efd5337

Check the return of setsockopt (#12772)

Emmanuel Vasilakis committed Apr 28, 2022 at 14:11 UTC 59efd533768ccd1713ab2ddcad5ff1d1d724fd41
1 file changed +2 -1
streaming/receiver.c
+2 -1
@@ -612,7 +612,8 @@ static int rrdpush_receive(struct receiver_state *rpt)
612 struct timeval timeout;
613 timeout.tv_sec = 120;
614 timeout.tv_usec = 0;
615 - setsockopt (rpt->fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout);
615 + if (unlikely(setsockopt(rpt->fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout) != 0))
616 + error("STREAM %s [receive from [%s]:%s]: cannot set timeout for socket %d", rpt->host->hostname, rpt->client_ip, rpt->client_port, rpt->fd);
617
618 // convert the socket to a FILE *
619 FILE *fp = fdopen(rpt->fd, "r");