]> code.citadel.org Git - citadel.git/blobdiff - citadel/citserver.c
ICQ changes
[citadel.git] / citadel / citserver.c
index 45e36721a170baa86aba19403a5cf164289f70fc..c5cc618a41f0dd3c467cb9453b8280ab59ab88b2 100644 (file)
@@ -40,6 +40,7 @@
 
 struct CitContext *ContextList = NULL;
 int ScheduledShutdown = 0;
+int do_defrag = 0;
 
 /*
  * Various things that need to be initialized at startup
@@ -48,6 +49,9 @@ void master_startup(void) {
        lprintf(7, "Opening databases\n");
        open_databases();
 
+       if (do_defrag)
+               defrag_databases();
+
        lprintf(7, "Checking floor reference counts\n");
        check_ref_counts();
 
@@ -135,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);
 
@@ -152,6 +153,17 @@ void cleanup_stuff(void *arg)
        }
 
 
+/*
+ * Get a dynamic symbol number for per-session user data.
+ * This API call should be made only ONCE per symbol per citserver run.
+ */
+int CtdlGetDynamicSymbol() 
+{
+       static unsigned int next_symbol = SYM_MAX;
+       return ++next_symbol;
+}
+
+
 
 /*
  * Return a pointer to some generic per-session user data.
@@ -805,15 +817,13 @@ 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, "    ");
        strcpy(CC->cs_clientname, "(unknown)");
        strcpy(CC->curr_user,"(not logged in)");
        strcpy(CC->net_node,"");
-       snprintf(CC->temp, sizeof CC->temp, "/tmp/CitServer.%d.%d", getpid(), CC->cs_pid);
+       snprintf(CC->temp, sizeof CC->temp, tmpnam(NULL));
        strcpy(CC->cs_room, "(no room)");
        strncpy(CC->cs_host, config.c_fqdn, sizeof CC->cs_host);
        CC->cs_host[sizeof CC->cs_host - 1] = 0;
@@ -853,10 +863,12 @@ void *context_loop(struct CitContext *con)
                lprintf(5, "citserver[%3d]: %s\n", CC->cs_pid, cmdbuf);
 
                /*
-                * Let other clients see the last command we executed, but
-                * exclude NOOP because that would be boring.
+                * Let other clients see the last command we executed, and
+                * update the idle time, but not NOOP, PEXP, or GEXP.
                 */
-               if (strncasecmp(cmdbuf, "NOOP", 4)) {
+               if ( (strncasecmp(cmdbuf, "NOOP", 4))
+                  && (strncasecmp(cmdbuf, "PEXP", 4))
+                  && (strncasecmp(cmdbuf, "GEXP", 4)) ) {
                        strcpy(CC->lastcmdname, "    ");
                        strncpy(CC->lastcmdname, cmdbuf, 4);
                        time(&CC->lastidle);
@@ -1240,6 +1252,9 @@ void *context_loop(struct CitContext *con)
                                    ERROR);
                        }
 
+               /* Run any after-each-command outines registered by modules */
+               PerformSessionHooks(EVT_CMD);
+
                } while(strncasecmp(cmdbuf, "QUIT", 4));
 
        cleanup(EXIT_NORMAL);