From 979b00e635074df38869a10533628beee5964418 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 27 Feb 2000 03:57:44 +0000 Subject: [PATCH] * Completed 'fsck'-like reference count verifier (server and client) --- citadel/ChangeLog | 4 +- citadel/citadel.c | 4 ++ citadel/citadel.rc | 1 + citadel/commands.c | 80 +++++++++++++++++++++++++++--- citadel/commands.h | 1 + citadel/messages.c | 50 ++++++++++++------- citadel/messages.h | 1 + citadel/messages/saveopt | 7 --- citadel/routines2.c | 98 +++++++++++++++++-------------------- citadel/serv_expire.c | 75 ++++++++++++++++++++++++++-- citadel/sysdep.c | 12 ++++- citadel/techdoc/session.txt | 17 +++++-- 12 files changed, 252 insertions(+), 98 deletions(-) delete mode 100644 citadel/messages/saveopt diff --git a/citadel/ChangeLog b/citadel/ChangeLog index e2728305c..208df46ed 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 1.472 2000/02/27 03:57:35 ajc +* Completed 'fsck'-like reference count verifier (server and client) + Revision 1.471 2000/02/26 18:30:40 ajc * Properly handle all aliases specified in network/mail.aliases for incoming SMTP mail (uses the alias() function, so if we replace that function with @@ -1672,4 +1675,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citadel.c b/citadel/citadel.c index c68173a68..e35044fa5 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -1253,6 +1253,10 @@ GSTA: termn8 = 0; do_internet_configuration(); break; + case 83: + check_message_base(); + break; + case 50: enter_config(2); break; diff --git a/citadel/citadel.rc b/citadel/citadel.rc index b195cac0d..c439f5d88 100644 --- a/citadel/citadel.rc +++ b/citadel/citadel.rc @@ -173,6 +173,7 @@ cmd=70,2,&.,&Aide,&Message edit: cmd=78,1,&.,&Aide,&Post cmd=80,2,&.,&Aide,&System configuration,&General cmd=82,2,&.,&Aide,&System configuration,&Internet +cmd=83,2,&.,&Aide,&System configuration,check &Message base cmd=29,0,&.,&Terminate,and &Quit cmd=30,0,&.,&Terminate,and &Stay online diff --git a/citadel/commands.c b/citadel/commands.c index c869fd47c..1ab8c15b7 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -1,12 +1,9 @@ /* - * Citadel/UX - * - * commands.c - front end for Citadel - * - * This version is the traditional command parser for room prompts. - * * $Id$ * + * This file contains functions which implement parts of the + * text-mode user interface. + * */ #include "sysdep.h" @@ -108,7 +105,7 @@ void print_express(void) putc(7, stdout); } color(BRIGHT_RED); - printf("---\n"); + printf("\r---\n"); while (serv_gets(buf), strcmp(buf, "000")) { printf("%s\n", buf); } @@ -136,7 +133,7 @@ void do_keepalive(void) return; time(&idlet); - /* Do a space-backspace to keep socksified telnet sessions open */ + /* Do a space-backspace to keep telnet sessions from idling out */ printf(" %c", 8); fflush(stdout); @@ -1129,3 +1126,70 @@ void keyopt(char *buf) { } color(DIM_WHITE); } + + + +/* + * Present a key-menu line choice type of thing + */ +char keymenu(char *menuprompt, char *menustring) { + int i, c, a; + int choices; + int do_prompt = 0; + char buf[256]; + int ch; + int display_prompt = 1; + + choices = num_tokens(menustring, '|'); + + if (menuprompt != NULL) do_prompt = 1; + if (menuprompt != NULL) if (strlen(menuprompt)==0) do_prompt = 0; + + while (1) { + if (display_prompt) { + if (do_prompt) { + printf("%s ", menuprompt); + } + else { + for (i=0; i "); + display_prompt = 0; + } + ch = lkey(); + + if ( (do_prompt) && (ch=='?') ) { + printf("\rOne of... "); + printf(" \n"); + for (i=0; i') ) { + for (a=0; a "); -MECR2: b=inkey(); - if (b==NEXT_KEY) b='n'; - if (b==STOP_KEY) b='s'; - b=(b&127); b=tolower(b); - if (b=='?') { - printf("Help\n"); - formout("saveopt"); - goto MECR1; - } - if (b=='a') { printf("Abort\n"); goto MEABT; } - if (b=='c') { printf("Continue\n"); goto ME1; } - if (b=='s') { printf("Save message\n"); goto MEFIN; } + + b = keymenu("Entry command (? for options)", + "bort|ontinue|ave message|

rint formatted|" + "eplace string|old message"); + + if (b=='a') goto MEABT; + if (b=='c') goto ME1; + if (b=='s') goto MEFIN; if (b=='p') { - printf("Print formatted\n"); printf(" %s from %s",datestr,fullname); if (strlen(recipient)>0) printf(" to %s",recipient); printf("\n"); @@ -700,15 +694,12 @@ MECR2: b=inkey(); goto MECR; } if (b=='r') { - printf("Replace string\n"); replace_string(filename,0L); goto MECR; } if (b=='h') { - printf("Hold message\n"); return(2); } - goto MECR2; MEFIN: return(0); @@ -1244,3 +1235,28 @@ void edit_system_message(char *which_message) sprintf(write_cmd, "EMSG %s", which_message); do_edit(desc, read_cmd, "NOOP", write_cmd); } + + + + +/* + * Verify the message base + */ +void check_message_base(void) { + char buf[256]; + + printf("Please read the documentation before running this command.\n"); + printf("Having done so, do you still want to check the message base? "); + if (yesno()==0) return; + + serv_puts("FSCK"); + serv_gets(buf); + if (buf[0] != '1') { + printf("%s\n", &buf[4]); + return; + } + + while (serv_gets(buf), strcmp(buf, "000")) { + printf("%s\n", buf); + } +} diff --git a/citadel/messages.h b/citadel/messages.h index 73523f76e..4af8f4286 100644 --- a/citadel/messages.h +++ b/citadel/messages.h @@ -6,3 +6,4 @@ void edit_system_message(char *which_message); extern int lines_printed; pid_t ka_wait(int *kstatus); void list_urls(void); +void check_message_base(void); diff --git a/citadel/messages/saveopt b/citadel/messages/saveopt deleted file mode 100644 index 20c01bb51..000000000 --- a/citadel/messages/saveopt +++ /dev/null @@ -1,7 +0,0 @@ -One of: - bort - ontinue - old this message -

rint formatted - eplace string (edit) - ave message diff --git a/citadel/routines2.c b/citadel/routines2.c index 23537c9b3..7efce58b4 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -813,61 +813,51 @@ void do_internet_configuration(void) { color(DIM_WHITE); } - keyopt("\ndd elete ave uit -> "); - do { - badkey = 0; - ch = inkey(); - ch = tolower(ch); - if ( (ch=='d') && (num_recs == 0) ) ch = 0; - switch(ch) { - case 'a': - printf("Add\n"); - ++num_recs; - if (num_recs == 1) - recs = malloc(sizeof(char *)); - else recs = realloc(recs, - (sizeof(char *)) * num_recs); - newprompt("Enter host name: ", - buf, 50); - strcat(buf, "|"); - get_inet_rec_type(&buf[strlen(buf)]); - recs[num_recs-1] = strdup(buf); - break; - case 'd': - printf("Delete\n"); - i = intprompt("Delete which one", - 1, 1, num_recs) - 1; - free(recs[i]); - --num_recs; - for (j=i; jdd|elete|ave|uit"); + switch(ch) { + case 'a': + ++num_recs; + if (num_recs == 1) + recs = malloc(sizeof(char *)); + else recs = realloc(recs, + (sizeof(char *)) * num_recs); + newprompt("Enter host name: ", + buf, 50); + strcat(buf, "|"); + get_inet_rec_type(&buf[strlen(buf)]); + recs[num_recs-1] = strdup(buf); + break; + case 'd': + i = intprompt("Delete which one", + 1, 1, num_recs) - 1; + free(recs[i]); + --num_recs; + for (j=i; jnext = rr; + ptr->msgnum = msgnum; + rr = ptr; +} + +void do_fsck_room(struct quickroom *qrbuf, void *data) +{ + getroom(&CC->quickroom, qrbuf->QRname); + CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, do_fsck_msg); +} + /* - * Check message reference counts (FIXME ... not yet finished) + * Check message reference counts + */ void cmd_fsck(char *argbuf) { long msgnum; struct cdbdata *cdbmsg; struct SuppMsgInfo smi; + struct roomref *ptr; + int realcount; - cprintf("%d This is not done yet.\n", LISTING_FOLLOWS); + if ( (!CC->logged_in) || (CC->usersupp.axlevel < 6) ) { + cprintf("%d Higher access required\n", + ERROR+HIGHER_ACCESS_REQUIRED); + return; + } + + /* Lame way of checking whether anyone else is doing this now */ + if (rr != NULL) { + cprintf("%d Another FSCK is already running.\n", ERROR); + return; + } + + cprintf("%d Checking message reference counts\n", LISTING_FOLLOWS); + + cprintf("\nThis could take a while. Please be patient!\n\n"); + cprintf("Gathering pointers...\n"); + ForEachRoom(do_fsck_room, NULL); get_control(); + cprintf("Checking message base...\n"); for (msgnum = 0L; msgnum <= CitControl.MMhighest; ++msgnum) { cdbmsg = cdb_fetch(CDB_MSGMAIN, &msgnum, sizeof(long)); @@ -552,15 +596,36 @@ void cmd_fsck(char *argbuf) { cprintf("Message %7ld ", msgnum); GetSuppMsgInfo(&smi, msgnum); - cprintf("refcount=%-2d \n", smi.smi_refcount); + cprintf("refcount=%-2d ", smi.smi_refcount); + + realcount = 0; + for (ptr = rr; ptr != NULL; ptr = ptr->next) { + if (ptr->msgnum == msgnum) ++realcount; + } + cprintf("realcount=%-2d\n", realcount); + + if ( (smi.smi_refcount != realcount) + || (realcount == 0) ) { + smi.smi_refcount = realcount; + PutSuppMsgInfo(&smi); + AdjRefCount(msgnum, 0); /* deletes if needed */ + } + } } + cprintf("Freeing memory...\n"); + while (rr != NULL) { + ptr = rr->next; + phree(rr); + rr = ptr; + } + + cprintf("Done!\n"); cprintf("000\n"); } - */ @@ -570,6 +635,6 @@ void cmd_fsck(char *argbuf) { char *Dynamic_Module_Init(void) { CtdlRegisterProtoHook(cmd_expi, "EXPI", "Expire old system objects"); -/* CtdlRegisterProtoHook(cmd_fsck, "FSCK", "Check message ref counts"); */ + CtdlRegisterProtoHook(cmd_fsck, "FSCK", "Check message ref counts"); return "$Id$"; } diff --git a/citadel/sysdep.c b/citadel/sysdep.c index d7eee1f73..53f48392c 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -501,7 +501,17 @@ int client_gets(char *buf) * The system-dependent part of master_cleanup() - close the master socket. */ void sysdep_master_cleanup(void) { - /* FIXME close all protocol master sockets here */ + struct ServiceFunctionHook *serviceptr; + + /* + * close all protocol master sockets + */ + for (serviceptr = ServiceHookTable; serviceptr != NULL; + serviceptr = serviceptr->next ) { + lprintf(3, "Closing listener on port %d\n", + serviceptr->tcp_port); + close(serviceptr->msock); + } } diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index 490375bab..1c0b0e0fe 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -1538,11 +1538,8 @@ UCLS command. -> _userpic_ (Server will attempt to write to the user's online photo) -> Any of the "well known" filenames described in the writeup for the OIMG command. - ----------------------------------------------- -The following are for citserver 5.02 and above ----------------------------------------------- - + + HCHG (Hostname CHanGe) HCHG is a command, usable by any user, that allows a user to change their RWHO @@ -1781,3 +1778,13 @@ and statuses. CICQ status Always returns OK followed by a 1 (connected to ICQ) or 0 (not connected). + + + + + FSCK (check message base reference counts) + + Verify, via the long way, that all message referenmce counts are correct. If +the user has permission to do this then LISTING_FOLLOWS is returned, followed +by a transcript of the run. Otherwise ERROR is returned. + -- 2.39.2