* trace whether we were shut down regular, or we crashed/were killed/...
* send an aide message if we unconditionaly exit.
/*
* 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;
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);
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
exit(0);
}
+int nFireUps = 0;
+int nFireUpsNonRestart = 0;
+pid_t ForkedPid = 1;
/*
* Start running as a daemon.
}
waitpid(current_child, &status, 0);
}
-
do_restart = 0;
-
+ nFireUpsNonRestart = nFireUps;
/* Did the main process exit with an actual exit code? */
if (WIFEXITED(status)) {
/* 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);
+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
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);