* make some pointers const...
authorWilfried Göesgens <willi@citadel.org>
Wed, 25 Mar 2009 23:18:46 +0000 (23:18 +0000)
committerWilfried Göesgens <willi@citadel.org>
Wed, 25 Mar 2009 23:18:46 +0000 (23:18 +0000)
* trace whether we were shut down regular, or we crashed/were killed/...
* send an aide message if we unconditionaly exit.

citadel/msgbase.c
citadel/msgbase.h
citadel/server_main.c
citadel/sysdep.c
citadel/sysdep_decls.h

index 8a1424a1bdc13cab74d059d6c3478ce3b8a6d6be..60648431e3e2c8e100b439a11522bda71cafcd4a 100644 (file)
@@ -3031,8 +3031,8 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
 /*
  * Convenience function for generating small administrative messages.
  */
-void quickie_message(char *from, char *fromaddr, char *to, char *room, char *text, 
-                       int format_type, char *subject)
+void quickie_message(const char *from, const char *fromaddr, char *to, char *room, const char *text, 
+                       int format_type, const char *subject)
 {
        struct CtdlMessage *msg;
        struct recptypes *recp = NULL;
index 56097736107ef9174d53c6a97963c95a4a4e9e36..4d487679112b9f0e2ac716143d6d6165aaf1a096 100644 (file)
@@ -100,7 +100,7 @@ void cmd_dlat (char *cmdbuf);
 long send_message (struct CtdlMessage *);
 void loadtroom (void);
 long CtdlSubmitMsg(struct CtdlMessage *, struct recptypes *, char *, int);
-void quickie_message (char *, char *, char *, char *, char *, int, char *);
+void quickie_message (const char *, const char *, char *, char *, const char *, int, const char *);
 void cmd_ent0 (char *entargs);
 void cmd_dele (char *delstr);
 void cmd_move (char *args);
index 2d7d65717a974bad19c388725350bcab7889e404..b3d110cd8b498b4631621fb143eb0989b65d390d 100644 (file)
@@ -310,6 +310,14 @@ int main(int argc, char **argv)
                start_chkpwd_daemon();
        }
 
+
+       /*
+        * check, whether we're fired up another time after a crash.
+        * if, post an aide message, so the admin has a chance to react.
+        */
+       checkcrash ();
+
+
        /*
         * Now that we've bound the sockets, change to the Citadel user id and its
         * corresponding group ids
index 995742b40d834cb379c886740128f965579126cb..359b4c33b7fa87c6ee91792525bfff922deef193 100644 (file)
@@ -896,6 +896,9 @@ void graceful_shutdown(int signum) {
        exit(0);
 }
 
+int nFireUps = 0;
+int nFireUpsNonRestart = 0;
+pid_t ForkedPid = 1;
 
 /*
  * Start running as a daemon.
@@ -951,9 +954,8 @@ void start_daemon(int unused) {
                        }
                        waitpid(current_child, &status, 0);
                }
-
                do_restart = 0;
-
+               nFireUpsNonRestart = nFireUps;
                /* Did the main process exit with an actual exit code? */
                if (WIFEXITED(status)) {
 
@@ -970,12 +972,16 @@ void start_daemon(int unused) {
                        /* Any other exit code means we should restart. */
                        else {
                                do_restart = 1;
+                               nFireUps++;
+                               ForkedPid = current_child;
                        }
                }
 
                /* Any other type of termination (signals, etc.) should also restart. */
                else {
                        do_restart = 1;
+                       nFireUps++;
+                       ForkedPid = current_child;
                }
 
        } while (do_restart);
@@ -986,6 +992,28 @@ void start_daemon(int unused) {
 
 
 
+void checkcrash(void)
+{
+       if (nFireUpsNonRestart != nFireUps)
+       {
+               StrBuf *CrashMail;
+
+               CrashMail = NewStrBuf();
+               CtdlLogPrintf (CTDL_ALERT, "----------------sending crash mail\n");
+               StrBufPrintf(CrashMail, 
+                            "Your CitServer is just recovering from an unexpected termination.\n"
+                            " this maybe the result of an error in citserver or an external influence.\n"
+                            " You can get more information on this by enabling coredumping; for more information see\n"
+                            " http://citadel.org/doku.php/faq:mastering_your_os:gdb#how.do.i.make.my.system.produce.core-files\n"
+                            " If you already did, the file you're looking for most probably is %score.%d\n"
+                            " Yours faithfully...",
+                            ctdl_run_dir, ForkedPid);
+               aide_message(ChrPtr(CrashMail), "Citadel server crashed.");
+               FreeStrBuf(&CrashMail);
+       }
+}
+
+
 /*
  * Generic routine to convert a login name to a full name (gecos)
  * Returns nonzero if a conversion took place
index 8a16f7305beb4915dfea149328c4c428a234118e..802ae3305df533dc778e528c3fc858db9886ffbd 100644 (file)
@@ -70,6 +70,7 @@ void sysdep_master_cleanup (void);
 void kill_session (int session_to_kill);
 void *sd_context_loop (struct CitContext *con);
 void start_daemon (int do_close_stdio);
+void checkcrash(void);
 void cmd_nset (char *cmdbuf);
 int convert_login (char *NameToConvert);
 void *worker_thread (void *arg);