/* We used to wait for all threads to exit. Fuck that. The only thing important...
authorArt Cancro <ajc@citadel.org>
Thu, 11 Feb 2021 02:06:17 +0000 (21:06 -0500)
committerArt Cancro <ajc@citadel.org>
Thu, 11 Feb 2021 02:06:17 +0000 (21:06 -0500)
* cleanly unmounted.  After that, exit the whole program.

citadel/database_cleanup.sh.in [changed mode: 0644->0755]
citadel/modules/rssclient/serv_rssclient.c
citadel/threads.c

old mode 100644 (file)
new mode 100755 (executable)
index bbfa646..e281549
@@ -5,11 +5,39 @@ die () {
        exit 1
 }
 
-# data dir from autoconf?
-DATA_DIR="@MAKE_DATA_DIR@"
-if test -z "$DATA_DIR" ; then
-       DATA_DIR="/usr/local/citadel"
+DATA_DIR="/usr/local/citadel"
+
+
+
+usage() {
+       echo "Usage: database_cleanup.sh [ -h citadel_dir ]"
+       exit 2
+}
+
+PARSED_ARGUMENTS=$(getopt -a -n database_cleanup.sh -o h: -- "$@")
+VALID_ARGUMENTS=$?
+if [ "$VALID_ARGUMENTS" != "0" ]; then
+       usage
 fi
+
+eval set -- "$PARSED_ARGUMENTS"
+while :
+do
+       case "$1" in
+               -h | --alpha)
+                       DATA_DIR=${2}
+                       shift 2
+                       ;;
+               # -- means the end of the arguments; drop this, and break out of the while loop
+               --) shift; break ;;
+               # If invalid options were passed, then getopt should have reported an error,
+               # which we checked as VALID_ARGUMENTS when getopt was called...
+               *) echo "Unexpected option: $1 - this should not happen."
+                       usage
+                       ;;
+       esac
+done
+
 DATA_DIR=$DATA_DIR/data
 
 # If we're on an Easy Install system, use our own db_ tools.
@@ -87,6 +115,7 @@ you will need `du -sh $DATA_DIR|sed "s;/.*;;"` of free space.
 
 !
 
+echo We will attempt to look for a Citadel database in $DATA_DIR
 echo -n "Do you want to continue? "
 
 read yesno
@@ -104,7 +133,10 @@ for x in 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d
 do
        filename=cdb.$x
        echo Dumping $filename
-       $DUMP -h $DATA_DIR $filename >/tmp/CitaDump.$x || die
+       $DUMP -h $DATA_DIR $filename >/tmp/CitaDump.$x || {
+               echo error $?
+               die
+       }
        rm -f $DATA_DIR/$filename
 done
 
index e8098e91c9c56e9d19f2812cf4d21e167f69cfe2..e0fba5fdcd4237da1a7057717ae6f3f03d91c470 100644 (file)
@@ -3,7 +3,7 @@
  * very loose parser that scrapes both kinds of feeds and is not picky about
  * the standards compliance of the source data.
  *
- * Copyright (c) 2007-2020 by the citadel.org team
+ * Copyright (c) 2007-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 3.
@@ -66,11 +66,12 @@ struct rssurl *rsstodo = NULL;
 
 // This handler is called whenever an XML tag opens.
 //
-void rss_start_element(void *data, const char *el, const char **attribute)
-{
+void rss_start_element(void *data, const char *el, const char **attribute) {
        struct rssparser *r = (struct rssparser *)data;
        int i;
 
+       if (server_shutting_down) return;                       // shunt the whole operation if we're exiting
+
        if (
                (!strcasecmp(el, "entry"))
                || (!strcasecmp(el, "item"))
@@ -104,11 +105,12 @@ void rss_start_element(void *data, const char *el, const char **attribute)
 
 // This handler is called whenever an XML tag closes.
 //
-void rss_end_element(void *data, const char *el)
-{
+void rss_end_element(void *data, const char *el) {
        struct rssparser *r = (struct rssparser *)data;
        StrBuf *encoded_field;
 
+       if (server_shutting_down) return;                       // shunt the whole operation if we're exiting
+
        if (StrLength(r->CData) > 0) {                          // strip leading/trailing whitespace from field
                StrBufTrim(r->CData);
        }
@@ -375,7 +377,7 @@ void rss_pull_feeds(void)
        struct rssurl *r;
        struct rssroom *rr;
 
-       while (rsstodo != NULL) {
+       while ((rsstodo != NULL) && (!server_shutting_down)) {
                rss_pull_one_feed(rsstodo);
                r = rsstodo;
                rsstodo = rsstodo->next;
@@ -400,6 +402,8 @@ void rssclient_scan_room(struct ctdlroom *qrbuf, void *data)
        char cfgline[SIZ];
        int i = 0;
 
+       if (server_shutting_down) return;
+
         serialized_config = LoadRoomNetConfigFile(qrbuf->QRnumber);
         if (!serialized_config) {
                return;
index 18641b5456491ce4201069b5cd55a64e6403b19c..21f585cdae75671707f0adcb33684f7ac30cb3cf 100644 (file)
@@ -167,6 +167,10 @@ void go_threading(void)
        CtdlShutdownServiceHooks();             /* close all listener sockets to prevent new connections */
        PerformSessionHooks(EVT_SHUTDOWN);      /* run any registered shutdown hooks */
 
+       /* We used to wait for all threads to exit.  Fuck that.  The only thing important is that the databases are
+        * cleanly unmounted.  After that, exit the whole program.
+        */
+#if 0
        int countdown = 30;
        while ( (num_workers > 0) && (countdown-- > 0)) {
                syslog(LOG_DEBUG, "Waiting %d seconds for %d worker threads to exit",
@@ -174,4 +178,6 @@ void go_threading(void)
                );
                usleep(1000000);
        }
+#endif
+
 }