[asterisk-commits] tilghman: branch 1.6.0 r116949 - in /branches/1.6.0: ./ utils/astcanary.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun May 18 16:18:06 CDT 2008


Author: tilghman
Date: Sun May 18 16:18:06 2008
New Revision: 116949

URL: http://svn.digium.com/view/asterisk?view=rev&rev=116949
Log:
Merged revisions 116948 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r116948 | tilghman | 2008-05-18 16:15:58 -0500 (Sun, 18 May 2008) | 4 lines

Add a set of text to the file astcanary uses to communicate back the main
Asterisk process, which explains the purpose for the file being there.  This
should assist people who find the file and wonder why it exists.

........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/utils/astcanary.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/utils/astcanary.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/utils/astcanary.c?view=diff&rev=116949&r1=116948&r2=116949
==============================================================================
--- branches/1.6.0/utils/astcanary.c (original)
+++ branches/1.6.0/utils/astcanary.c Sun May 18 16:18:06 2008
@@ -24,6 +24,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <string.h>
 
 /*!\brief
  * At one time, canaries were carried along with coal miners down
@@ -58,6 +59,19 @@
  * Asterisk itself.
  */
 
+const char explanation[] =
+"This file is created when Asterisk is run with a realtime priority (-p).  It\n"
+"must continue to exist, and the astcanary process must be allowed to continue\n"
+"running, or else the Asterisk process will, within a short period of time,\n"
+"slow itself down to regular priority.\n\n"
+"The technical explanation for this file is to provide an assurance to Asterisk\n"
+"that there are no threads that have gone into runaway mode, thus hogging the\n"
+"CPU, and making the Asterisk machine seem to be unresponsive.  When that\n"
+"happens, the astcanary process will be unable to update the timestamp on this\n"
+"file, and Asterisk will notice within 120 seconds and react.  Slowing the\n"
+"Asterisk process down to regular priority will permit an administrator to\n"
+"intervene, thus avoiding a need to reboot the entire machine.\n";
+
 int main(int argc, char *argv[])
 {
 	int fd;
@@ -67,10 +81,12 @@
 		/* Update the modification times (checked from Asterisk) */
 		if (utime(argv[1], NULL)) {
 			/* Recreate the file if it doesn't exist */
-			if ((fd = open(argv[1], O_RDWR | O_TRUNC | O_CREAT, 0777)) > -1)
+			if ((fd = open(argv[1], O_RDWR | O_TRUNC | O_CREAT, 0777)) > -1) {
+				write(fd, explanation, strlen(explanation));
 				close(fd);
-			else
+			} else {
 				exit(1);
+			}
 			continue;
 		}
 




More information about the asterisk-commits mailing list