From 80360a5e4c39b0f4dd8241a3b08ab1667ea69b6b Mon Sep 17 00:00:00 2001 From: msweet Date: Tue, 23 Jul 2013 12:33:52 +0000 Subject: [PATCH] Closed server connections were still not always detected () - Also need to check for EOF from recv... git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11174 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.6.txt | 2 ++ cups/request.c | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGES-1.6.txt b/CHANGES-1.6.txt index 96da1a537e..c224ca0cd2 100644 --- a/CHANGES-1.6.txt +++ b/CHANGES-1.6.txt @@ -3,6 +3,8 @@ CHANGES-1.6.txt CHANGES IN CUPS V1.6.4 + - Closed server connections were still not always detected + () - The libusb-based USB backend now loads its list of quirks from files in /usr/share/cups/usb instead of using a hardcoded table () diff --git a/cups/request.c b/cups/request.c index 9f0995ba30..0ccb499656 100644 --- a/cups/request.c +++ b/cups/request.c @@ -1017,14 +1017,15 @@ _cupsConnect(void) * Same server, see if the connection is still established... */ - char ch; /* Connection check byte */ + char ch; /* Connection check byte */ + ssize_t n; /* Number of bytes */ #ifdef WIN32 - if (recv(cg->http->fd, &ch, 1, MSG_PEEK) < 0 && - WSAGetLastError() != WSAEWOULDBLOCK) + if ((n = recv(cg->http->fd, &ch, 1, MSG_PEEK)) == 0 || + (n < 0 && WSAGetLastError() != WSAEWOULDBLOCK)) #else - if (recv(cg->http->fd, &ch, 1, MSG_PEEK | MSG_DONTWAIT) < 0 && - errno != EWOULDBLOCK) + if ((n = recv(cg->http->fd, &ch, 1, MSG_PEEK | MSG_DONTWAIT)) == 0 || + (n < 0 && errno != EWOULDBLOCK)) #endif /* WIN32 */ { /* -- 2.47.2