* Removed code from some of the utilities which was still attempting
authorArt Cancro <ajc@citadel.org>
Tue, 29 Sep 1998 17:25:52 +0000 (17:25 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 29 Sep 1998 17:25:52 +0000 (17:25 +0000)
          to access the old non-gdbm data store.
        * housekeeping.c: rewrote check_ref_counts() to do a ForEachRoom()
          traversal instead of a MAXROOMS loop.
        * sysdep.c: set up a dummy CitContext record to be used during server
          startup, during which time there is no real context.

citadel/ChangeLog
citadel/citserver.c
citadel/housekeeping.c
citadel/msgbase.c
citadel/netproc.c
citadel/rcit.c
citadel/sysdep.c

index f1b157162a65e7b38aca5c5273ec5a139cfff4aa..cbb7dc9382348f3c7d9d34ec35a3d77a0d2fb9a0 100644 (file)
@@ -1,3 +1,11 @@
+Tue Sep 29 13:20:14 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+       * Removed code from some of the utilities which was still attempting
+         to access the old non-gdbm data store.
+       * housekeeping.c: rewrote check_ref_counts() to do a ForEachRoom()
+         traversal instead of a MAXROOMS loop.
+       * sysdep.c: set up a dummy CitContext record to be used during server
+         startup, during which time there is no real context.
+
 Mon Sep 28 23:51:51 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Implemented the function ForEachRoom() to handle all-rooms traversal
          (this will work with both the old and new paradigms, because both
index 781e41893f7c6ddd52b173130dfcabc8505de2c5..5219cdb628aaab8db8d14540e87871db9442cfa3 100644 (file)
@@ -38,7 +38,6 @@ void master_startup(void) {
 
        lprintf(7, "Checking floor reference counts\n");
        check_ref_counts();
-       
        }
 
 /*
index bff8910878a0dcf7a64f999b867420f1b730d143..2458fa861ff20e128f802bfcbeeb3a1e9fa81d62 100644 (file)
@@ -71,27 +71,29 @@ void do_housekeeping(void) {
 /*
  * Check (and fix) floor reference counts.  This doesn't need to be done
  * very often, since the counts should remain correct during normal operation.
+ * NOTE: this function pair should ONLY be called during startup.  It is NOT
+ * thread safe.
  */
+void check_ref_counts_backend(struct quickroom *qrbuf) {
+       struct floor flbuf;
+
+       lgetfloor(&flbuf, qrbuf->QRfloor);
+       ++flbuf.f_ref_count;
+       flbuf.f_flags = flbuf.f_flags | QR_INUSE;
+       lputfloor(&flbuf, qrbuf->QRfloor);
+       }
+
 void check_ref_counts(void) {
-       int ref[MAXFLOORS];
-       struct quickroom qrbuf;
        struct floor flbuf;
        int a;
 
-       for (a=0; a<MAXFLOORS; ++a) ref[a] = 0;
-               
-       for (a=0; a<MAXROOMS; ++a) {
-               getroom(&qrbuf, a);
-               if (qrbuf.QRflags & QR_INUSE) {
-                       ++ref[(int)qrbuf.QRfloor];
-                       }
-               }
-
        for (a=0; a<MAXFLOORS; ++a) {
                lgetfloor(&flbuf, a);
-               flbuf.f_ref_count = ref[a];
-               if (ref[a] > 0) flbuf.f_flags = flbuf.f_flags | QR_INUSE ;
+               flbuf.f_ref_count = 0;
+               flbuf.f_flags = flbuf.f_flags & ~QR_INUSE;
                lputfloor(&flbuf, a);
                }
+
+       ForEachRoom(check_ref_counts_backend);
        }       
 
index 076eee5e25bf7509748c419cb8690ed83b0b7038..d9b570c83464e0c7d0e14d3c58a348e99e00b9bf 100644 (file)
@@ -139,11 +139,11 @@ void get_mm(void) {
  */
 void cmd_msgs(char *cmdbuf)
 {
-       int a;
-       int mode;
+       int a = 0;
+       int mode = 0;
        char which[256];
-       int cm_howmany;
-       long cm_gt;
+       int cm_howmany = 0;
+       long cm_gt = 0L;
 
        extract(which,cmdbuf,0);
 
@@ -651,6 +651,8 @@ long send_message(char *message_in_memory,  /* pointer to buffer */
 
 /* FIX ... rewrite this to simply check for the existence of the twitroom,
  * and create it if necessary.  No slot-numbers will need to be loaded.
+ * (Actually, twitroom should be created during the same portion of startup
+ * that creates Lobby/Mail/Aide.)
  */
 void loadtroom(void) {
        struct quickroom qrbuf;
index 52dafca1c3815802753f15d52d66fd41520de689..5f18db114cff0e2a4a4798834f3d680a0d1dc6d8 100644 (file)
@@ -103,8 +103,6 @@ void serv_write(char *buf, int nbytes);
 void get_config(void);
 
 struct filterlist *filter = NULL;
-char roomnames[MAXROOMS][20];
-char roomdirs[MAXROOMS][15];
 struct syslist *slist = NULL;
 
 struct config config;
@@ -133,30 +131,6 @@ void strip_trailing_whitespace(char *buf)
        }
 
 
-/*
- * for performance optimization, netproc loads the list of room names (and
- * their corresponding directory names, if applicable) into a table in memory.
- */
-int load_roomnames(void) {
-       FILE *fp;
-       struct quickroom qbuf;
-       int i;
-
-       fp=fopen("./quickroom","rb");
-       if (fp==NULL) return(1);
-       for (i=0; i<MAXROOMS; ++i) {
-               if (fread((char *)&qbuf,sizeof(struct quickroom),1,fp)!=1)
-                       return(1);
-               strcpy(roomnames[i],qbuf.QRname);
-               if (qbuf.QRflags & QR_DIRECTORY)
-                       strcpy(roomdirs[i],qbuf.QRdirname);
-               else
-                       strcpy(roomdirs[i],config.c_bucket_dir);
-               }
-       fclose(fp);
-       return(0);
-       }
-
 /*
  * we also load the network/mail.sysinfo table into memory, make changes
  * as we learn more about the network from incoming messages, and write
@@ -580,16 +554,18 @@ void ship_to(char *filenm, char *sysnm)   /* send spool file filenm to system sysn
 
 /*
  * proc_file_transfer()  -  handle a simple file transfer packet
+ *
+ * FIX  This shouldn't be like this.  What it needs to do is begin an upload
+ * and transmit the file to the server.
  */
 void proc_file_transfer(char *tname)
 {      /* name of temp file containing the whole message */
        char buf[128];
-       char dest_dir[32];
+       char dest_room[32];
        FILE *tfp,*uud;
-       int a,b;
+       int a;
 
        printf("netproc: processing network file transfer...\n");
-       strcpy(dest_dir,config.c_bucket_dir);
 
        tfp=fopen(tname,"rb");
        if (tfp==NULL) printf("netproc: cannot open %s\n",tname);
@@ -598,9 +574,8 @@ void proc_file_transfer(char *tname)
                a=getc(tfp);
                if (a!='M') {
                        fpgetfield(tfp,buf);
-                       if (a=='O') for (b=0; b<MAXROOMS; ++b) {
-                               if (!strcasecmp(buf,roomnames[b]))
-                                       strcpy(dest_dir,roomdirs[b]);
+                       if (a=='O') {
+                               strcpy(dest_room, buf);
                                }
                        }
                } while ((a!='M')&&(a>=0));
@@ -610,7 +585,7 @@ void proc_file_transfer(char *tname)
                return;
                }
 
-       sprintf(buf,"cd %s/files/%s; exec %s",bbs_home_directory,dest_dir,UUDECODE);
+       sprintf(buf,"cd %s/files/%s; exec %s",bbs_home_directory,config.c_bucket_dir,UUDECODE);
        uud=(FILE *)popen(buf,"w");
        if (uud==NULL) {
                printf("netproc: cannot open uudecode pipe\n");
@@ -1275,7 +1250,6 @@ void main(int argc, char **argv)
        np_attach_to_server();
        fflush(stdout);
 
-       if (load_roomnames()!=0) fprintf(stdout,"netproc: cannot load rooms\n");
        if (load_syslist()!=0) fprintf(stdout,"netproc: cannot load sysinfo\n");
        setup_special_nodes();
 
index 6ab12e1e32fb9514fb9ec0c452d6b052b7c23ede..6f1ef65a3ba7a60e89c424a57ad4915130d67588 100644 (file)
@@ -1,7 +1,7 @@
 #define UNCOMPRESS "/usr/bin/gunzip"
 
-/* Citadel/UX rnews
- * version 2.8
+/* Citadel/UX rcit
+ * version 2.9
  *
  * This program functions the same as the standard rnews program for
  * UseNet. It accepts standard input, and looks for rooms to post messages
 void get_config(void);
 struct config config;
 
-char roomlist[MAXROOMS][20];
-
-void load_roomlist(void) {
-       FILE *fp;
-       struct quickroom QRtemp;
-       int a;
-
-       for (a=0; a<MAXROOMS; ++a) strcpy(roomlist[a],TWITROOM);
-       fp=fopen("quickroom","r");
-       if (fp==NULL) return;
-       for (a=0; a<MAXROOMS; ++a) {
-               fread((char *)&QRtemp,sizeof(struct quickroom),1,fp);
-               if (QRtemp.QRflags & QR_INUSE)
-                       strcpy(roomlist[a],QRtemp.QRname);
-               }
-       fclose(fp);
-       }
-
-
-
-int rnewsxref(char *room, char *ngroup)                /* xref table */
-             
-               {
+/*
+ * Cross-reference newsgroup names to Citadel room names
+ */
+int rnewsxref(char *room, char *ngroup) {
        FILE *fp;
        int a,b;
        char aaa[50],bbb[50];
@@ -87,30 +68,6 @@ GNA: strcpy(aaa,""); strcpy(bbb,"");
        }
 
 
-void getroom(char *room, char *ngroup)
-{
-       char ngbuf[256];
-       char tryme[256];
-       int a,b;
-       struct quickroom qbuf;
-
-       strcpy(ngbuf,ngroup);
-       strcat(ngbuf,",");
-       for (a=0; a<strlen(ngbuf); ++a) {
-               if ((ngbuf[a]==',')||(ngbuf[a]==0)) {
-                       strcpy(tryme,ngbuf);    
-                       tryme[a]=0;
-                       if (!rnewsxref(room,tryme)) return;
-                       room[sizeof(qbuf.QRname)-1]=0;
-                       for (b=0; b<MAXROOMS; ++b) {
-                               if (!strcasecmp(roomlist[b],room)) return;
-                               }
-                       strcpy(ngbuf,&ngbuf[a+1]);
-                       a=(-1);
-                       }
-               }
-       }
-
 void main(int argc, char **argv)
 {
        char aaa[128],bbb[128],ccc[128];
@@ -149,7 +106,6 @@ void main(int argc, char **argv)
                }
 
        /* process UseNet news input */
-       load_roomlist();
 A:     if (fgets(aaa,128,minput)==NULL) goto END;
        aaa[strlen(aaa)-1]=0;
        if (strncmp(aaa,"#! rnews ",9)) goto A;
@@ -246,7 +202,7 @@ C:  if ((author[0]==0)||(room[0]==0)||(node[0]==0)) goto ABORT;
        fprintf(mout,"T%ld",now); putc(0,mout);
        fprintf(mout,"A%s",author); putc(0,mout);
        strcpy(ccc,room);
-       getroom(room,ccc);
+       rnewsxref(room,ccc);
        fprintf(mout,"O%s",room); putc(0,mout);
        fprintf(mout,"N%s",node); putc(0,mout);
        if (orgname[0]!=0) {
index 87ca119fd3a0896a9610ece6dbf9dbe62d4d091a..1220155690896468ff7673d47196ad43c0db0945 100644 (file)
@@ -49,6 +49,8 @@ pthread_key_t MyConKey;                               /* TSD key for MyContext() */
 int msock;                                     /* master listening socket */
 int verbosity = 3;                             /* Logging level */
 
+struct CitContext masterCC;
+
 
 /*
  * lprintf()  ...   Write logging information
@@ -211,7 +213,10 @@ int ig_tcp_server(int port_number, int queue_len)
  * Return a pointer to a thread's own CitContext structure (new)
  */
 struct CitContext *MyContext(void) {
-       return (struct CitContext *) pthread_getspecific(MyConKey);
+       struct CitContext *retCC;
+       retCC = (struct CitContext *) pthread_getspecific(MyConKey);
+       if (retCC == NULL) retCC = &masterCC;
+       return(retCC);
        }
 
 
@@ -656,14 +661,8 @@ int main(int argc, char **argv)
        lprintf(7, "Loading citadel.config\n");
        get_config();
 
-       /* Databases must be opened *after* config is loaded, otherwise we might
-        * end up working in the wrong directory.
-        */
-       lprintf(7, "Opening databases\n");
-       open_databases();
-
-       lprintf(7, "Checking floor reference counts\n");
-       check_ref_counts();
+       /* Do non system dependent startup functions */
+       master_startup();
 
        /*
         * Bind the server to our favourite port.