Walter Steiner wrote:
>
> In my case (Solaris 8, outlook client) the problem of dying imapds
> isn't fixed yet. I think it dies in the second call to idle_poll()
> (alarm timer). This might be related to ...
>
> According to the signal(3C) man page on Solaris 8:
>
> void (*signal (int sig, void (*disp)(int)))(int);
>
> If signal() is
> used, disp is the address of a signal handler, and sig is
> not SIGILL, SIGTRAP, or SIGPWR, the system first sets the
> signal's disposition to SIG_DFL before executing the signal
> handler.
>
> SIG_DFL remains after idle_poll() is first called by the alarm timer.
Damn! My Linux development system treats unreliable signals as
reliable, so I never caught this glaring error. I just verified that
the current code will NOT work correctly on Solaris 7+ and IRIX 6.x.
Thanks for pointing this out.
> There should be at least two ways to fix the problem:
>
> 1) add the signal() call in idle_init() to idle_poll() also
>
> idle_update(IDLE_MAILBOX|IDLE_ALERT);
>
> + signal(SIGALRM, idle_poll);
> alarm(idle_period);
>
> 2) use sigset() instead of signal() in idle_init() (on Solaris (?, 7, 8))
>
> Is this an appropriate fix? (either one is working for me ... I think,-)
Either solution will work, except Linux apparently doesn't have
sigset(). So I checked in a different fix (below) which uses POSIX
signal sets (to conform with similar code in master.c)
Ken
*** idle_poll.c 2001/01/16 16:54:26 1.2
--- idle_poll.c 2001/01/17 17:26:59
***************
*** 40,47 ****
--- 40,50 ----
/* $Id: idle_poll.c,v 1.2 2001/01/16 16:54:26 ken3 Exp $ */
+ #include <syslog.h>
#include <time.h>
+ #ifdef HAVE_UNISTD_H
#include <unistd.h>
+ #endif
#include <signal.h>
#include "idle.h"
***************
*** 75,85 ****
int idle_init(struct mailbox *mailbox, idle_updateproc_t *proc)
{
idle_update = proc;
/* Setup the mailbox polling function to be called at
'idle_period'
seconds from now */
! signal(SIGALRM, idle_poll);
alarm(idle_period);
return 1;
--- 78,100 ----
int idle_init(struct mailbox *mailbox, idle_updateproc_t *proc)
{
+ struct sigaction action;
+
idle_update = proc;
/* Setup the mailbox polling function to be called at
'idle_period'
seconds from now */
! sigemptyset(&action.sa_mask);
! action.sa_flags = 0;
! #ifdef SA_RESTART
! action.sa_flags |= SA_RESTART;
! #endif
! action.sa_handler = idle_poll;
! if (sigaction(SIGALRM, &action, NULL) < 0) {
! syslog(LOG_ERR, "sigaction: %m");
! return 0;
! }
!
alarm(idle_period);
return 1;
--
Kenneth Murchison Oceana Matrix Ltd.
Software Engineer 21 Princeton Place
716-662-8973 x26 Orchard Park, NY 14127
--PGP Public Key-- http://www.oceana.com/~ken/ksm.pgp