bug which was causing the server to occasionally crash.
+Sun Dec 13 17:40:08 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+ * sysdep.c, citserver.c: (hopefully) fixed a session table concurrency
+ bug which was causing the server to occasionally crash.
+
Fri Dec 11 18:50:00 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* setup.c: default value for maxsessions is now 0 (no limit)
* room_ops.c: don't allow users to create a room called "Mail"
{
int session_num;
struct CitContext *ccptr;
+ int session_to_kill = 0;
if (!CC->logged_in) {
cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
return;
}
+ begin_critical_section(S_SESSION_TABLE);
for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
if (session_num == ccptr->cs_pid) {
- kill_session(ccptr->cs_pid);
- cprintf("%d Session terminated.\n", OK);
- return;
+ session_to_kill = ccptr->cs_pid;
}
}
+ end_critical_section(S_SESSION_TABLE);
- cprintf("%d No such session.\n", ERROR);
+ if (session_to_kill > 0) {
+ kill_session(ccptr->cs_pid);
+ cprintf("%d Session terminated.\n", OK);
+ }
+ else {
+ cprintf("%d No such session.\n", ERROR);
+ }
}
void *context_loop(struct CitContext *con)
{
char cmdbuf[256];
- int session_num;
+ int num_sessions;
/*
* Wedge our way into the context table.
CC->upload_type = UPL_FILE;
CC->dl_is_net = 0;
- session_num = session_count();
+ num_sessions = session_count();
CC->nologin = 0;
- if ((config.c_maxsessions > 0)&&(session_num > config.c_maxsessions))
+ if ((config.c_maxsessions > 0)&&(num_sessions > config.c_maxsessions))
CC->nologin = 1;
if (CC->nologin==1) {
return;
}
+ /*
+ * session_count() starts its own S_SESSION_TABLE critical section;
+ * so do not call it from within this loop.
+ */
begin_critical_section(S_SESSION_TABLE);
lprintf(7, "Closing socket %d\n", con->client_socket);
close(con->client_socket);
lprintf(9, "Freeing session context...\n");
free(con);
lprintf(9, "...done.\n");
+ end_critical_section(S_SESSION_TABLE);
lprintf(9, "Session count after RemoveContext is %d\n",
session_count());
lprintf(7, "Done with RemoveContext\n");
- end_critical_section(S_SESSION_TABLE);
}
int TheCount = 0;
lprintf(9, "session_count() starting\n");
+ begin_critical_section(S_SESSION_TABLE);
for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {
++TheCount;
lprintf(9, "Counted session %3d (%d)\n", ptr->cs_pid, TheCount);
}
+ end_critical_section(S_SESSION_TABLE);
lprintf(9, "session_count() finishing\n");
return(TheCount);