]> code.citadel.org Git - citadel.git/blobdiff - citadel/room_ops.c
* Buffered output needs to be flushed in several places. Added calls to
[citadel.git] / citadel / room_ops.c
index 2b80cabae660df0fc16f066de762ac9edbc49721..0566282098297fa7d46ddb6fcd2d8c81056e7882 100644 (file)
@@ -140,9 +140,10 @@ int CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf)
                }
        }
 
-       /* On some systems, Aides can gain access to mailboxes as well */
-       if ( (config.c_aide_mailboxes)
-          && (userbuf->axlevel >= 6)
+       /* Aides can gain access to mailboxes as well, but they don't show
+        * by default.
+        */
+       if ( (userbuf->axlevel >= 6)
           && (roombuf->QRflags & QR_MAILBOX) ) {
                retval = retval | UA_GOTOALLOWED;
        }
@@ -333,17 +334,31 @@ void lgetfloor(struct floor *flbuf, int floor_num)
 struct floor *cgetfloor(int floor_num) {
        static int initialized = 0;
        int i;
+       int fetch_new = 0;
+       struct floor *fl = NULL;
 
+       begin_critical_section(S_FLOORCACHE);
        if (initialized == 0) {
                for (i=0; i<MAXFLOORS; ++i) {
                        floorcache[floor_num] = NULL;
                }
        initialized = 1;
        }
-       
        if (floorcache[floor_num] == NULL) {
-               floorcache[floor_num] = mallok(sizeof(struct floor));
-               getfloor(floorcache[floor_num], floor_num);
+               fetch_new = 1;
+       }
+       end_critical_section(S_FLOORCACHE);
+
+       if (fetch_new) {
+               lprintf(CTDL_DEBUG, "fetch_new is active ... going to disk\n");
+               fl = malloc(sizeof(struct floor));
+               getfloor(fl, floor_num);
+               begin_critical_section(S_FLOORCACHE);
+               if (floorcache[floor_num] != NULL) {
+                       free(floorcache[floor_num]);
+               }
+               floorcache[floor_num] = fl;
+               end_critical_section(S_FLOORCACHE);
        }
 
        return(floorcache[floor_num]);
@@ -356,14 +371,17 @@ struct floor *cgetfloor(int floor_num) {
  */
 void putfloor(struct floor *flbuf, int floor_num)
 {
-       cdb_store(CDB_FLOORTAB, &floor_num, sizeof(int),
-                 flbuf, sizeof(struct floor));
-
        /* If we've cached this, clear it out, 'cuz it's WRONG now! */
+       begin_critical_section(S_FLOORCACHE);
        if (floorcache[floor_num] != NULL) {
-               phree(floorcache[floor_num]);
-               floorcache[floor_num] = NULL;
+               free(floorcache[floor_num]);
+               floorcache[floor_num] = malloc(sizeof(struct floor));
+               memcpy(floorcache[floor_num], flbuf, sizeof(struct floor));
        }
+       end_critical_section(S_FLOORCACHE);
+
+       cdb_store(CDB_FLOORTAB, &floor_num, sizeof(int),
+                 flbuf, sizeof(struct floor));
 }
 
 
@@ -788,7 +806,7 @@ void usergoto(char *where, int display_result, int transiently,
        get_mm();
         cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
         if (cdbfr != NULL) {
-               msglist = mallok(cdbfr->len);
+               msglist = malloc(cdbfr->len);
                memcpy(msglist, cdbfr->ptr, cdbfr->len);
                num_msgs = cdbfr->len / sizeof(long);
                cdb_free(cdbfr);
@@ -803,7 +821,7 @@ void usergoto(char *where, int display_result, int transiently,
                }
        }
 
-       if (msglist != NULL) phree(msglist);
+       if (msglist != NULL) free(msglist);
 
        if (CC->room.QRflags & QR_MAILBOX)
                rmailflag = 1;
@@ -1692,7 +1710,12 @@ void cmd_cre8(char *args)
 
        if (num_parms(args) >= 5) {
                fl = cgetfloor(extract_int(args, 4));
-               if ((fl->f_flags & F_INUSE) == 0) {
+               if (fl == NULL) {
+                       cprintf("%d Invalid floor number.\n",
+                               ERROR + INVALID_FLOOR_OPERATION);
+                       return;
+               }
+               else if ((fl->f_flags & F_INUSE) == 0) {
                        cprintf("%d Invalid floor number.\n",
                                ERROR + INVALID_FLOOR_OPERATION);
                        return;
@@ -1720,8 +1743,7 @@ void cmd_cre8(char *args)
        }
 
        if (new_room_type == 5) {
-               if ((config.c_aide_mailboxes == 0)
-                  || (CC->user.axlevel < 6)) {
+               if (CC->user.axlevel < 6) {
                        cprintf("%d Higher access required\n", 
                                ERROR + HIGHER_ACCESS_REQUIRED);
                        return;
@@ -1792,6 +1814,7 @@ void cmd_einf(char *ok)
                return;
        }
        cprintf("%d Send info...\n", SEND_LISTING);
+       flush_output();
 
        do {
                client_gets(buf);