From owner-svn-src-head@FreeBSD.ORG Mon Jul 1 21:33:05 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B04B1CBF; Mon, 1 Jul 2013 21:33:05 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A2FF21333; Mon, 1 Jul 2013 21:33:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r61LX5RW064309; Mon, 1 Jul 2013 21:33:05 GMT (envelope-from asomers@svn.freebsd.org) Received: (from asomers@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r61LX5Lo064308; Mon, 1 Jul 2013 21:33:05 GMT (envelope-from asomers@svn.freebsd.org) Message-Id: <201307012133.r61LX5Lo064308@svn.freebsd.org> From: Alan Somers Date: Mon, 1 Jul 2013 21:33:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r252482 - head/sbin/devd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 21:33:05 -0000 Author: asomers Date: Mon Jul 1 21:33:05 2013 New Revision: 252482 URL: http://svnweb.freebsd.org/changeset/base/252482 Log: Add a SIGINFO handler to devd. It will send useful statistics to syslog or stderr as appropriate. Currently, the only statistic printed is the number of events received. Reviewed by: eadler Approved by: gibbs (co-mentor) Modified: head/sbin/devd/devd.cc Modified: head/sbin/devd/devd.cc ============================================================================== --- head/sbin/devd/devd.cc Mon Jul 1 21:20:17 2013 (r252481) +++ head/sbin/devd/devd.cc Mon Jul 1 21:33:05 2013 (r252482) @@ -117,6 +117,8 @@ static struct pidfh *pfh; int dflag; int nflag; +static unsigned total_events = 0; +static volatile sig_atomic_t got_siginfo = 0; static volatile sig_atomic_t romeo_must_die = 0; static const char *configfile = CF; @@ -965,6 +967,11 @@ event_loop(void) tv.tv_usec = 0; } rv = select(max_fd, &fds, NULL, NULL, &tv); + if (got_siginfo) { + devdlog(LOG_INFO, "Events received so far=%ld\n", + total_events); + got_siginfo = 0; + } if (rv == -1) { if (errno == EINTR) continue; @@ -974,6 +981,7 @@ event_loop(void) if (FD_ISSET(fd, &fds)) { rv = read(fd, buffer, sizeof(buffer) - 1); if (rv > 0) { + total_events++; if (rv == sizeof(buffer) - 1) { devdlog(LOG_WARNING, "Warning: " "available event data exceeded " @@ -1091,6 +1099,16 @@ gensighand(int) } /* + * SIGINFO handler. Will print useful statistics to the syslog or stderr + * as appropriate + */ +static void +siginfohand(int) +{ + got_siginfo = 1; +} + +/* * Local logging function. Prints to syslog if we're daemonized; syslog * otherwise. */ @@ -1169,6 +1187,7 @@ main(int argc, char **argv) signal(SIGHUP, gensighand); signal(SIGINT, gensighand); signal(SIGTERM, gensighand); + signal(SIGINFO, siginfohand); event_loop(); return (0); }