[15572] in Athena Bugs

home help back first fref pref prev next nref lref last post

alarm conflict between syslogd and ZInitialize

daemon@ATHENA.MIT.EDU (mhpower@MIT.EDU)
Sun Oct 12 19:40:34 1997

From: <mhpower@MIT.EDU>
To: bugs@MIT.EDU
Date: Sun, 12 Oct 1997 19:40:29 EDT

The zephyr syslogd arranges for the function domark to be called
approximately every 30 seconds using an approach that begins with
calling "alarm(TIMERINTVL)". Unfortunately, after the call
"alarm(TIMERINTVL)" occurs, there is a call to ZInitialize.
ZInitialize calls ZhmStat, which calls "alarm(0)". This results in
syslogd never calling domark, and because of that delivery of some
syslog data can be inordinately delayed.

Possibly the correct fix is for the zephyr library to either avoid
using alarm, or to use some different approach that involves looking
at the return value of alarm. This may well be of benefit to other
zephyr clients that use alarm, and perhaps also exhibited anomalous
behavior upon being linked with a version of the zephyr library that
includes ZhmStat.

However, the simplest fix appears to be changing syslogd to do its
signal-related tasks after calling ZInitialize. The patch is relative
to /mit/source/athena/lib/zephyr/clients/syslogd/syslogd.c

Matt


*** syslogd.c.old	Mon Sep 15 00:02:50 1997
--- syslogd.c	Sun Oct 12 19:10:48 1997
***************
*** 377,409 ****
  	else
  		LocalDomain = "";
- #ifdef _POSIX_VERSION
- 	action.sa_flags = 0;
- 	sigemptyset(&action.sa_mask);
- 
- 	action.sa_handler = die;
- 	sigaction(SIGTERM, &action, NULL);
- 
- 	action.sa_handler = Debug ? die : SIG_IGN;
- 	sigaction(SIGINT, &action, NULL);
- 	sigaction(SIGQUIT, &action, NULL);
- 
- 	action.sa_handler = reapchild;
- 	sigaction(SIGCHLD, &action, NULL);
- 
- 	action.sa_handler = domark;
- 	sigaction(SIGALRM, &action, NULL);
- #else
- 	(void) signal(SIGTERM, die);
- 	if (Debug) {
- 		(void) signal(SIGINT, die);
- 		(void) signal(SIGQUIT, die);
- 	} else {
- 		(void) signal(SIGINT, SIG_IGN);
- 		(void) signal(SIGQUIT, SIG_IGN);
- 	}
- 	(void) signal(SIGCHLD, reapchild);
- 	(void) signal(SIGALRM, domark);
- #endif
- 	(void) alarm(TIMERINTVL);
   
  #ifndef STREAMS_LOG_DRIVER
--- 377,380 ----
***************
*** 501,504 ****
--- 472,505 ----
  	znotice.z_default_format = "Syslog message from $instance, level $opcode:\n$message";
  	(void) ZInitialize ();
+ 
+ #ifdef _POSIX_VERSION
+ 	action.sa_flags = 0;
+ 	sigemptyset(&action.sa_mask);
+ 
+ 	action.sa_handler = die;
+ 	sigaction(SIGTERM, &action, NULL);
+ 
+ 	action.sa_handler = Debug ? die : SIG_IGN;
+ 	sigaction(SIGINT, &action, NULL);
+ 	sigaction(SIGQUIT, &action, NULL);
+ 
+ 	action.sa_handler = reapchild;
+ 	sigaction(SIGCHLD, &action, NULL);
+ 
+ 	action.sa_handler = domark;
+ 	sigaction(SIGALRM, &action, NULL);
+ #else
+ 	(void) signal(SIGTERM, die);
+ 	if (Debug) {
+ 		(void) signal(SIGINT, die);
+ 		(void) signal(SIGQUIT, die);
+ 	} else {
+ 		(void) signal(SIGINT, SIG_IGN);
+ 		(void) signal(SIGQUIT, SIG_IGN);
+ 	}
+ 	(void) signal(SIGCHLD, reapchild);
+ 	(void) signal(SIGALRM, domark);
+ #endif
+ 	(void) alarm(TIMERINTVL);
  
  	init(0);

home help back first fref pref prev next nref lref last post