[PATCH} avoid busy-wait on diskd overload

From: Vladimir B. Savkin <master@dont-contact.us>
Date: Sat, 8 Dec 2001 21:19:11 +0300

Hello!

The following patch against 2.5-HEAD prevents squid from entering
busy-wait state on diskd queue overflow. It is accomplished by using
blocking msgrcv call.

Index: src/fs/diskd/store_dir_diskd.c
===================================================================
RCS file: /squid/squid/src/fs/diskd/store_dir_diskd.c,v
retrieving revision 1.58
diff -u -r1.58 store_dir_diskd.c
--- src/fs/diskd/store_dir_diskd.c 2001/11/13 18:11:20 1.58
+++ src/fs/diskd/store_dir_diskd.c 2001/12/08 18:09:00
@@ -503,18 +503,18 @@
     diskdinfo_t *diskdinfo = SD->fsdata;
     int retval = 0;
 
- if (diskdinfo->away >= diskdinfo->magic2) {
- diskd_stats.block_queue_len++;
- retval = 1; /* We might not have anything to do, but our queue
- * is full.. */
- }
     if (diskd_stats.sent_count - diskd_stats.recv_count >
         diskd_stats.max_away) {
         diskd_stats.max_away = diskd_stats.sent_count - diskd_stats.recv_count;
     }
     while (1) {
+ int block = diskdinfo->away >= diskdinfo->magic2;
+
+ if (block)
+ diskd_stats.block_queue_len++;
         memset(&M, '\0', sizeof(M));
- x = msgrcv(diskdinfo->rmsgid, &M, msg_snd_rcv_sz, 0, IPC_NOWAIT);
+ x = msgrcv(diskdinfo->rmsgid, &M, msg_snd_rcv_sz, 0,
+ block ? 0 : IPC_NOWAIT);
         if (x < 0)
             break;
         else if (x != msg_snd_rcv_sz) {

:wq
                                        With best regards,
                                           Vladimir Savkin.
Received on Sat Dec 08 2001 - 11:19:15 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:40 MST