From f287bfce6bc4682dc5bb4963b4f6fd82e015cefc Mon Sep 17 00:00:00 2001 From: octo Date: Thu, 1 Jun 2006 07:17:11 +0000 Subject: [PATCH] ntpd branch: Close the ntpd-socket if a read or write failes (with something else then EAGAIN or EINTR). --- src/ntpd.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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); } -- 2.30.2