On 13-09-14 00:46, Sam Varshavchik wrote:
Kees Bakker writes:

In my case it would have been helpful if something useful had been
written in a log file, any log file. Now, I was completely in the dark
about the failure. On my system the mentioned "FAMPending: timeout"
was not in the log.
So, if possible, write an error message in the log that imapd died due to timeout. Is the alarm(15) signal handled at all, or does the program simply
die? If so, that seems like a misfeature.

Patches are always welcome.

Well, that is not so easy for me. I don't have the development setup nor
the knowledge to create patches. I'm just a courier user (who happens to
know C programming :-)
A patch would be something like the attached. But you are in a much better
position to fill in the gaps.

diff --git a/maildir/maildirwatch.c b/maildir/maildirwatch.c
index cc73782..d14f113 100644
--- a/maildir/maildirwatch.c
+++ b/maildir/maildirwatch.c
@@ -12,6 +12,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
+#include <signal.h>
+#include <sys/signal.h>
 
 #ifndef PATH_MAX
 #define PATH_MAX 4096
@@ -20,6 +22,13 @@
 
 #if HAVE_FAM
 static struct maildirwatch_fam *maildirwatch_currentfam;
+static void alarm_handler(int signum)
+{
+	if (signum == SIGALRM) {
+		// Write to the (sys)log saying something like: "FAMopen took too long, giving up..." ??
+		// exit ??
+	}
+}
 #endif
 
 struct maildirwatch *maildirwatch_alloc(const char *maildir)
@@ -58,6 +67,7 @@ struct maildirwatch *maildirwatch_alloc(const char *maildir)
 			maildirwatch_currentfam->broken=0;
 			maildirwatch_currentfam->refcnt=0;
 
+			signal(SIGALRM, alarm_handler);
 			alarm(15);
 			if (FAMOpen(&maildirwatch_currentfam->fc) < 0)
 			{
@@ -65,6 +75,7 @@ struct maildirwatch *maildirwatch_alloc(const char *maildir)
 				free(maildirwatch_currentfam);
 				maildirwatch_currentfam=NULL;
 			}
+			signal(SIGALRM, SIG_DFL);
 			alarm(0);
 		}
 	}
------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Courier-imap mailing list
Courier-imap@lists.sourceforge.net
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap

Reply via email to