Return-Path: Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 5718 invoked by uid 500); 26 Sep 2002 00:11:57 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 5705 invoked from network); 26 Sep 2002 00:11:56 -0000 Date: Thu, 26 Sep 2002 02:11:59 +0200 (CEST) From: Dirk-Willem van Gulik X-X-Sender: dirkx@foem.leiden.webweaving.org To: dev@httpd.apache.org Subject: [PATCH] Alerting when fnctl is going bad Message-ID: <20020926021132.U80210-100000@foem.leiden.webweaving.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Now this may be a bit linux specific - but I'd like to get something like this in; if needed with a #ifdef DIAG or on a per platform basis. It is just something I've found to come in handy at various times - in particular on Linux and with lots of heavy PHP or mod_perl. This patch does two things -> Collapes the near identical mutex_fcnt on/off functions into one. -> Makes the wait loop no longer endless - but causes it to bail out (and emit some warnings ahead of time) after a couple of thousand consequituve EINTRs. Does this make sense ? Objections ? Dw Index: http_main.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v retrieving revision 1.592 diff -u -r1.592 http_main.c --- http_main.c 21 Sep 2002 17:18:34 -0000 1.592 +++ http_main.c 26 Sep 2002 00:07:20 -0000 @@ -885,37 +885,51 @@ unlink(ap_lock_fname); } -static void accept_mutex_on_fcntl(void) +static void accept_mutex(struct flock * flag) { - int ret; - - while ((ret = fcntl(lock_fd, F_SETLKW, &lock_it)) < 0 && errno == EINTR) { - /* nop */ + int ret,count = 0; + while ((ret = fcntl(lock_fd, F_SETLKW, flag)) < 0 && errno == EINTR) { + count++; + if (count & 0x20) { + ap_log_error(APLOG_MARK, + APLOG_INFO|APLOG_NOERRNO,server_conf, + "fcntl_mutex(%slock): many EINTR's, keep trying", + flag->l_type == F_UNLCK ? "un" : ""); + if (count > 5000) { + ap_log_error(APLOG_MARK,APLOG_EMERG,server_conf, + "fcntl_mutex(%slock): %d EINTR's in" + " a row, child exiting...", + flag->l_type == F_UNLCK ? "un" : "",count); + clean_child_exit(APEXIT_CHILDFATAL); + } + } } if (ret < 0) { ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf, - "fcntl: F_SETLKW: Error getting accept lock, exiting! " - "Perhaps you need to use the LockFile directive to place " - "your lock file on a local disk!"); + "fcntl: F_SETLKW: Error %slocking accept lock, exiting! " + "Perhaps you need to use the LockFile directive to place " + "your lock file on a local disk!", + flag->l_type == F_UNLCK ? "un" : ""); clean_child_exit(APEXIT_CHILDFATAL); } + + if (count > 50) { + ap_log_error(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,server_conf, + "fcntl_mutex(%slock): got EINTR %d consequitive times, " + "and finally succeeded", + flag->l_type == F_UNLCK ? "un" : "",count); + } } -static void accept_mutex_off_fcntl(void) +static void accept_mutex_on_fcntl(void) { - int ret; + return accept_mutex(&lock_it); +} - while ((ret = fcntl(lock_fd, F_SETLKW, &unlock_it)) < 0 && errno == EINTR) { - /* nop */ - } - if (ret < 0) { - ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf, - "fcntl: F_SETLKW: Error freeing accept lock, exiting! " - "Perhaps you need to use the LockFile directive to place " - "your lock file on a local disk!"); - clean_child_exit(APEXIT_CHILDFATAL); - } +static void accept_mutex_off_fcntl(void) +{ + return accept_mutex(&unlock_it); } accept_mutex_methods_s accept_mutex_fcntl_s = {