From: octo Date: Thu, 1 Jun 2006 07:17:11 +0000 (+0000) Subject: ntpd branch: Close the ntpd-socket if a read or write failes (with something else... X-Git-Tag: svn-trunk~12^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f287bfce6bc4682dc5bb4963b4f6fd82e015cefc;p=collectd.git ntpd branch: Close the ntpd-socket if a read or write failes (with something else then EAGAIN or EINTR). --- diff --git a/src/ntpd.c b/src/ntpd.c index 40c2aa47..e6d0ae28 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -560,6 +560,9 @@ static int ntpd_receive_response (int req_code, int *res_items, int *res_size, if (status < 0) { DBG ("recv(2) failed: %s", strerror (errno)); + DBG ("Closing socket #%i", sd); + close (sd); + sock_descr = sd = -1; return (-1); } @@ -758,7 +761,12 @@ static int ntpd_send_request (int req_code, int req_items, int req_size, char *r status = swrite (sd, (const char *) &req, REQ_LEN_NOMAC); if (status < 0) + { + DBG ("`swrite' failed. Closing socket #%i", sd); + close (sd); + sock_descr = sd = -1; return (status); + } return (0); }