From: wessels <> Date: Thu, 28 May 1998 00:36:11 +0000 (+0000) Subject: while loop in icpHandleUdp X-Git-Tag: SQUID_3_0_PRE1~3241 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5b0aaa58dc11343c004e6ec5d21a5d5d2d995b36;p=thirdparty%2Fsquid.git while loop in icpHandleUdp --- diff --git a/src/icp_v2.cc b/src/icp_v2.cc index d85e5f3832..630171285f 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -305,51 +305,57 @@ icpHandleUdp(int sock, void *datanotused) LOCAL_ARRAY(char, buf, SQUID_UDP_SO_RCVBUF); int len; int icp_version; - + int max = 16; commSetSelect(sock, COMM_SELECT_READ, icpHandleUdp, NULL, 0); - from_len = sizeof(from); - memset(&from, '\0', from_len); - len = recvfrom(sock, - buf, - SQUID_UDP_SO_RCVBUF - 1, - 0, - (struct sockaddr *) &from, - &from_len); - if (len < 0) { + while (max--) { + from_len = sizeof(from); + memset(&from, '\0', from_len); + len = recvfrom(sock, + buf, + SQUID_UDP_SO_RCVBUF - 1, + 0, + (struct sockaddr *) &from, + &from_len); + if (len == 0) + break; + if (len < 0) { + if (ignoreErrno(errno)) + break; #ifdef _SQUID_LINUX_ - /* Some Linux systems seem to set the FD for reading and then - * return ECONNREFUSED when sendto() fails and generates an ICMP - * port unreachable message. */ - /* or maybe an EHOSTUNREACH "No route to host" message */ - if (errno != ECONNREFUSED && errno != EHOSTUNREACH) + /* Some Linux systems seem to set the FD for reading and then + * return ECONNREFUSED when sendto() fails and generates an ICMP + * port unreachable message. */ + /* or maybe an EHOSTUNREACH "No route to host" message */ + if (errno != ECONNREFUSED && errno != EHOSTUNREACH) #endif - debug(50, 1) ("icpHandleUdp: FD %d recvfrom: %s\n", - sock, xstrerror()); - return; - } - icpCount(buf, RECV, (size_t) len, 0); - buf[len] = '\0'; - debug(12, 4) ("icpHandleUdp: FD %d: received %d bytes from %s.\n", - sock, - len, - inet_ntoa(from.sin_addr)); + debug(50, 1) ("icpHandleUdp: FD %d recvfrom: %s\n", + sock, xstrerror()); + break; + } + icpCount(buf, RECV, (size_t) len, 0); + buf[len] = '\0'; + debug(12, 4) ("icpHandleUdp: FD %d: received %d bytes from %s.\n", + sock, + len, + inet_ntoa(from.sin_addr)); #ifdef ICP_PACKET_DUMP - icpPktDump(buf); + icpPktDump(buf); #endif - if (len < sizeof(icp_common_t)) { - debug(12, 4) ("icpHandleUdp: Ignoring too-small UDP packet\n"); - return; + if (len < sizeof(icp_common_t)) { + debug(12, 4) ("icpHandleUdp: Ignoring too-small UDP packet\n"); + break; + } + icp_version = (int) buf[1]; /* cheat! */ + if (icp_version == ICP_VERSION_2) + icpHandleIcpV2(sock, from, buf, len); + else if (icp_version == ICP_VERSION_3) + icpHandleIcpV3(sock, from, buf, len); + else + debug(12, 0) ("WARNING: Unused ICP version %d received from %s:%d\n", + icp_version, + inet_ntoa(from.sin_addr), + ntohs(from.sin_port)); } - icp_version = (int) buf[1]; /* cheat! */ - if (icp_version == ICP_VERSION_2) - icpHandleIcpV2(sock, from, buf, len); - else if (icp_version == ICP_VERSION_3) - icpHandleIcpV3(sock, from, buf, len); - else - debug(12, 0) ("WARNING: Unused ICP version %d received from %s:%d\n", - icp_version, - inet_ntoa(from.sin_addr), - ntohs(from.sin_port)); } void