From 3334c6073b74551d18176701092179deb5b9ef06 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 10 Feb 2021 21:06:17 -0500 Subject: [PATCH] /* 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. --- citadel/database_cleanup.sh.in | 42 +++++++++++++++++++--- citadel/modules/rssclient/serv_rssclient.c | 16 +++++---- citadel/threads.c | 6 ++++ 3 files changed, 53 insertions(+), 11 deletions(-) mode change 100644 => 100755 citadel/database_cleanup.sh.in diff --git a/citadel/database_cleanup.sh.in b/citadel/database_cleanup.sh.in old mode 100644 new mode 100755 index bbfa64674..e2815497d --- a/citadel/database_cleanup.sh.in +++ b/citadel/database_cleanup.sh.in @@ -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 diff --git a/citadel/modules/rssclient/serv_rssclient.c b/citadel/modules/rssclient/serv_rssclient.c index e8098e91c..e0fba5fdc 100644 --- a/citadel/modules/rssclient/serv_rssclient.c +++ b/citadel/modules/rssclient/serv_rssclient.c @@ -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; diff --git a/citadel/threads.c b/citadel/threads.c index 18641b545..21f585cda 100644 --- a/citadel/threads.c +++ b/citadel/threads.c @@ -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 + } -- 2.30.2