]> code.citadel.org Git - citadel.git/blobdiff - citadel/citserver.c
* We now have a housekeeping thread and a housekeeping queue.
[citadel.git] / citadel / citserver.c
index 45d23b95e9f5c879bd8b6ee8debcb1a97d6182f6..195b42637de6052050b0c939813742fddc84a542 100644 (file)
@@ -28,8 +28,8 @@
 #include "housekeeping.h"
 #include "user_ops.h"
 #include "logging.h"
-#include "support.h"
 #include "msgbase.h"
+#include "support.h"
 #include "locate_host.h"
 #include "room_ops.h"
 #include "file_ops.h"
@@ -41,7 +41,6 @@
 struct CitContext *ContextList = NULL;
 int ScheduledShutdown = 0;
 int do_defrag = 0;
-int (*CtdlSendExpressMessageFunc) (char *, char *, char *) = NULL;
 
 /*
  * Various things that need to be initialized at startup
@@ -140,9 +139,6 @@ void cleanup_stuff(void *arg)
 
        syslog(LOG_NOTICE,"session %d ended", CC->cs_pid);
        
-       /* Deallocate any message list we might have in memory */
-       if (CC->msglist != NULL) phree(CC->msglist);
-
        /* Deallocate any user-data attached to this session */
        deallocate_user_data(CC);
 
@@ -150,10 +146,8 @@ void cleanup_stuff(void *arg)
        lprintf(7, "cleanup_stuff() calling RemoveContext(%d)\n", CC->cs_pid);
        RemoveContext(CC);
 
-       /* While we still have an extra thread with no user attached to it,
-        * take the opportunity to do some housekeeping before exiting.
-        */
-       do_housekeeping();
+       /* Wake up the housekeeping thread */
+       enter_housekeeping_cmd("SCHED_SHUTDOWN");
        }
 
 
@@ -199,15 +193,14 @@ void CtdlAllocUserData(unsigned long requested_sym, size_t num_bytes)
 
        lprintf(9, "CtdlAllocUserData(%ld) called\n", requested_sym);
 
+       /* Fail silently if the symbol is already registered. */
        for (ptr = CC->FirstSessData; ptr != NULL; ptr = ptr->next)  {
                if (ptr->sym_id == requested_sym) {
-                       lprintf(2, "ERROR: CtdlAllocUserData() requested for"
-                               " symbol id %ld already registered\n", 
-                               requested_sym);
                        return;
                }
        }
 
+       /* Grab us some memory!  Dem's good eatin' !!  */
        ptr = mallok(sizeof(struct CtdlSessData));
        ptr->sym_id = requested_sym;
        ptr->sym_data = mallok(num_bytes);
@@ -437,6 +430,7 @@ void cmd_iden(char *argbuf)
        strncpy(CC->cs_clientname,desc,31);
        CC->cs_clientname[31] = 0;
 
+       lprintf(9, "Looking up hostname\n");
        if ((strlen(from_host)>0) && 
           (is_public_client(CC->cs_host))) {
                if (inet_aton(from_host, &addr))
@@ -446,6 +440,8 @@ void cmd_iden(char *argbuf)
                        CC->cs_host[24] = 0;
                        }
                }
+
+       lprintf(9, "Setting wtmpsupp\n");
        set_wtmpsupp_to_current_room();
 
        syslog(LOG_NOTICE,"client %d/%d/%01d.%02d (%s)\n",
@@ -601,7 +597,7 @@ void cmd_rwho(void) {
        char un[40], room[40], host[40], flags[5];
        
        aide = CC->usersupp.axlevel >= 6;
-       cprintf("%d\n",LISTING_FOLLOWS);
+       cprintf("%d%c \n", LISTING_FOLLOWS, check_express() );
        
        for (cptr = ContextList; cptr != NULL; cptr = cptr->next) 
        {
@@ -662,6 +658,12 @@ void cmd_rwho(void) {
                
                }
        }
+
+       /* Now it's magic time.  Before we finish, call any EVT_RWHO hooks
+        * so that external paging modules such as serv_icq can add more
+        * content to the Wholist.
+        */
+       PerformSessionHooks(EVT_RWHO);
        cprintf("000\n");
        }
 
@@ -749,6 +751,7 @@ void cmd_ipgm(char *argbuf)
                }
        else {
                cprintf("%d Authentication failed.\n",ERROR);
+               lprintf(3, "Warning: ipgm authentication failed.\n");
                }
        }
 
@@ -758,7 +761,7 @@ void cmd_ipgm(char *argbuf)
  */
 void cmd_down(void) {
        if (!CC->logged_in) {
-               cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
+               cprintf("%d Not logged in.\n", ERROR+NOT_LOGGED_IN);
                return;
                }
 
@@ -821,8 +824,6 @@ void *context_loop(struct CitContext *con)
        CC->upload_fp = NULL;
        CC->cs_pid = con->client_socket;        /* not necessarily portable */
        CC->FirstExpressMessage = NULL;
-       CC->msglist = NULL;
-       CC->num_msgs = 0;
        time(&CC->lastcmd);
        time(&CC->lastidle);
        strcpy(CC->lastcmdname, "    ");
@@ -1058,10 +1059,6 @@ void *context_loop(struct CitContext *con)
                        cmd_gnur();
                        }
 
-               else if (!strncasecmp(cmdbuf,"GREG",4)) {
-                       cmd_greg(&cmdbuf[5]);
-                       }
-
                else if (!strncasecmp(cmdbuf,"VALI",4)) {
                        cmd_vali(&cmdbuf[5]);
                        }
@@ -1074,10 +1071,6 @@ void *context_loop(struct CitContext *con)
                        cmd_list();
                        }
 
-               else if (!strncasecmp(cmdbuf,"REGI",4)) {
-                       cmd_regi();
-                       }
-
                else if (!strncasecmp(cmdbuf,"CHEK",4)) {
                        cmd_chek();
                        }