From 48382032d06e18ea4ac99bf5ef74b81e752991f0 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Wed, 15 Jul 1998 04:55:59 +0000 Subject: [PATCH] Fixed select-spin bug when an ICP reply actually gets queued and we failed to execute the write callback --- ChangeLog | 2 ++ src/comm.cc | 4 +++- src/globals.h | 3 ++- src/icp_v2.cc | 30 ++++++++++++++++-------------- src/protos.h | 1 + 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index dcfe6de29b..b4a5cf2383 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,8 @@ - Moved 'miss_access' ACL check from client_side.c to forward.c - Fixed logging of usernames for requests which require proxy-authentication. + - Fixed select-spin bug when an ICP reply actually gets queued + and we failed to execute the write callback. Changes to squid-1.2.beta22 (June 1, 1998): diff --git a/src/comm.cc b/src/comm.cc index 53dcb4393b..8a58dface0 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,7 +1,7 @@ /* - * $Id: comm.cc,v 1.272 1998/06/26 04:23:33 wessels Exp $ + * $Id: comm.cc,v 1.273 1998/07/14 22:55:59 wessels Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -777,6 +777,8 @@ comm_incoming(void) icpHandleUdp(theInIcpConnection, &incame); if (theInIcpConnection != theOutIcpConnection) icpHandleUdp(theOutIcpConnection, &incame); + if (IcpQueueHead) + icpUdpSendQueue(theOutIcpConnection, NULL); } for (j = 0; j < NHttpSockets; j++) { if (HttpSockets[j] < 0) diff --git a/src/globals.h b/src/globals.h index 348b6f0560..896571633e 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.59 1998/06/02 21:38:08 rousskov Exp $ + * $Id: globals.h,v 1.60 1998/07/14 22:56:00 wessels Exp $ */ extern FILE *debug_log; /* NULL */ @@ -106,3 +106,4 @@ extern const char *StoreDigestUrlPath; /* "store_digest" */ extern const char *StoreDigestMimeStr; /* "application/cache-digest" */ extern const Version CacheDigestVer; /* { 3, 3 } */ extern const char *MultipartMsgBoundaryStr; /* "Unique-Squid-Separator" */ +extern icpUdpData *IcpQueueHead; /* NULL */ diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 32e1ccdef6..f94520bc02 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -3,11 +3,13 @@ static void icpLogIcp(struct in_addr, log_type, int, const char *, int); static void icpHandleIcpV2(int, struct sockaddr_in, char *, int); -static PF icpUdpSendQueue; static void icpCount(void *, int, size_t, int); -static icpUdpData *UdpQueueHead = NULL; -static icpUdpData *UdpQueueTail = NULL; +/* + * IcpQueueHead is global so comm_incoming() knows whether or not + * to call icpUdpSendQueue. + */ +static icpUdpData *IcpQueueTail = NULL; static void icpLogIcp(struct in_addr caddr, log_type logcode, int len, const char *url, int delay) @@ -30,17 +32,17 @@ icpLogIcp(struct in_addr caddr, log_type logcode, int len, const char *url, int accessLogLog(&al); } -static void +void icpUdpSendQueue(int fd, void *unused) { icpUdpData *q; int x; int delay; - while ((q = UdpQueueHead) != NULL) { + while ((q = IcpQueueHead) != NULL) { delay = tvSubUsec(q->queue_time, current_time); /* increment delay to prevent looping */ x = icpUdpSend(fd, &q->address, q->msg, q->logcode, ++delay); - UdpQueueHead = q->next; + IcpQueueHead = q->next; safe_free(q); if (x < 0) break; @@ -109,15 +111,15 @@ icpUdpSend(int fd, queue->len = (int) ntohs(msg->length); queue->queue_time = current_time; queue->logcode = logcode; - if (UdpQueueHead == NULL) { - UdpQueueHead = queue; - UdpQueueTail = queue; - } else if (UdpQueueTail == UdpQueueHead) { - UdpQueueTail = queue; - UdpQueueHead->next = queue; + if (IcpQueueHead == NULL) { + IcpQueueHead = queue; + IcpQueueTail = queue; + } else if (IcpQueueTail == IcpQueueHead) { + IcpQueueTail = queue; + IcpQueueHead->next = queue; } else { - UdpQueueTail->next = queue; - UdpQueueTail = queue; + IcpQueueTail->next = queue; + IcpQueueTail = queue; } commSetSelect(fd, COMM_SELECT_WRITE, icpUdpSendQueue, NULL, 0); Counter.icp.replies_queued++; diff --git a/src/protos.h b/src/protos.h index 33f950c0ff..6810816c30 100644 --- a/src/protos.h +++ b/src/protos.h @@ -440,6 +440,7 @@ extern void *icpCreateMessage(icp_opcode opcode, int pad); extern int icpUdpSend(int, const struct sockaddr_in *, icp_common_t *, log_type, int); extern PF icpHandleUdp; +extern PF icpUdpSendQueue; extern PF httpAccept; #ifdef SQUID_SNMP -- 2.47.3