#endif
struct CitContext *ContextList = NULL;
+struct CitContext* next_session = NULL;
char *unique_session_numbers;
int ScheduledShutdown = 0;
int do_defrag = 0;
/* Do system-dependent stuff */
sysdep_master_cleanup();
+#ifdef DEBUG_MEMORY_LEAKS
+ dump_heap();
+#endif
+
/* Now go away. */
lprintf(CTDL_NOTICE, "citserver: exiting.\n");
fflush(stdout); fflush(stderr);
lprintf(CTDL_DEBUG, "Deallocating user data symbol %ld\n",
con->FirstSessData->sym_id);
if (con->FirstSessData->sym_data != NULL)
- phree(con->FirstSessData->sym_data);
+ free(con->FirstSessData->sym_data);
ptr = con->FirstSessData->next;
- phree(con->FirstSessData);
+ free(con->FirstSessData);
con->FirstSessData = ptr;
}
end_critical_section(S_SESSION_TABLE);
else {
for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {
if (ptr->next == con) {
+ /* See fair scheduling in sysdep.c */
+ if (next_session == ptr->next)
+ next_session = ptr->next->next;
ToFree = ptr->next;
ptr->next = ptr->next->next;
--num_sessions;
/* This is where we used to check for scheduled shutdowns. */
/* Free up the memory used by this context */
- phree(con);
+ free(con);
lprintf(CTDL_DEBUG, "Done with RemoveContext()\n");
}
}
/* Grab us some memory! Dem's good eatin' !! */
- ptr = mallok(sizeof(struct CtdlSessData));
+ ptr = malloc(sizeof(struct CtdlSessData));
ptr->sym_id = requested_sym;
- ptr->sym_data = mallok(num_bytes);
+ ptr->sym_data = malloc(num_bytes);
memset(ptr->sym_data, 0, num_bytes);
begin_critical_section(S_SESSION_TABLE);
for (ptr = CC->FirstSessData; ptr != NULL; ptr = ptr->next) {
if (ptr->sym_id == requested_sym) {
- ptr->sym_data = reallok(ptr->sym_data, num_bytes);
+ ptr->sym_data = realloc(ptr->sym_data, num_bytes);
return;
}
}
/*
- * returns an asterisk if there are any express messages waiting,
+ * returns an asterisk if there are any instant messages waiting,
* space otherwise.
*/
char CtdlCheckExpress(void) {
extract(buf,mname,0);
- dirs[0]=mallok(64);
- dirs[1]=mallok(64);
+ dirs[0]=malloc(64);
+ dirs[1]=malloc(64);
strcpy(dirs[0],"messages");
strcpy(dirs[1],"help");
snprintf(buf2, sizeof buf2, "%s.%d.%d", buf, CC->cs_clientdev, CC->cs_clienttyp);
mesg_locate(targ,sizeof targ,buf,2,(const char **)dirs);
}
}
- phree(dirs[0]);
- phree(dirs[1]);
+ free(dirs[0]);
+ free(dirs[1]);
if (strlen(targ)==0) {
cprintf("%d '%s' not found.\n",ERROR + FILE_NOT_FOUND, mname);
if (buf[a] == '/') buf[a] = '.';
}
- dirs[0]=mallok(64);
- dirs[1]=mallok(64);
+ dirs[0]=malloc(64);
+ dirs[1]=malloc(64);
strcpy(dirs[0],"messages");
strcpy(dirs[1],"help");
mesg_locate(targ,sizeof targ,buf,2,(const char**)dirs);
- phree(dirs[0]);
- phree(dirs[1]);
+ free(dirs[0]);
+ free(dirs[1]);
if (strlen(targ)==0) {
snprintf(targ, sizeof targ, "./help/%s", buf);
config.c_nodename, config.c_maxsessions);
}
else {
- cprintf("%d %s Citadel/UX server ready.\n",
+ cprintf("%d %s Citadel server ready.\n",
CIT_OK, config.c_nodename);
}
}
time(&CC->lastcmd);
memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
if (client_gets(cmdbuf) < 1) {
- lprintf(CTDL_ERR, "Client socket is broken. Ending session.\n");
+ lprintf(CTDL_ERR, "Client socket is broken; ending session\n");
CC->kill_me = 1;
return;
}
}
if (!strncasecmp(cmdbuf,"NOOP",4)) {
- cprintf("%d%cok\n",CIT_OK,CtdlCheckExpress());
+ cprintf("%d%cok\n", CIT_OK, CtdlCheckExpress() );
}
else if (!strncasecmp(cmdbuf,"QNOP",4)) {
}
else if (!strncasecmp(cmdbuf,"QUIT",4)) {
- cprintf("%d Goodbye.\n",CIT_OK);
+ cprintf("%d Goodbye.\n", CIT_OK);
CC->kill_me = 1;
}
else if (!strncasecmp(cmdbuf,"LOUT",4)) {
if (CC->logged_in) logout(CC);
- cprintf("%d logged out.\n",CIT_OK);
+ cprintf("%d logged out.\n", CIT_OK);
}
else if (!strncasecmp(cmdbuf,"USER",4)) {
cmd_isme(&cmdbuf[5]);
}
-#ifdef DEBUG_MEMORY_LEAKS
- else if (!strncasecmp(cmdbuf, "LEAK", 4)) {
- dump_tracked();
- }
-#endif
-
else if (!DLoader_Exec_Cmd(cmdbuf)) {
- cprintf("%d Unrecognized or unsupported command.\n", ERROR + CMD_NOT_SUPPORTED);
+ cprintf("%d Unrecognized or unsupported command.\n",
+ ERROR + CMD_NOT_SUPPORTED);
}
- /* Run any after-each-command outines registered by modules */
+ /* Run any after-each-command routines registered by modules */
PerformSessionHooks(EVT_CMD);
}
+
+
+/*
+ * This loop performs all asynchronous functions.
+ */
+void do_async_loop(void) {
+ PerformSessionHooks(EVT_ASYNC);
+}