From d6afb4bcf56a594be1833988b5cc485ff797b671 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 28 Oct 1999 03:20:18 +0000 Subject: [PATCH] * Fixed the problem of worker threads waking up prematurely. * 'QUIT'-terminated sessions now exit properly. Still need to fix code for sessions which are terminated from another session or by the server. --- citadel/ChangeLog | 10 ++++++---- citadel/citserver.c | 6 ++---- citadel/sysdep.c | 14 ++------------ 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 0040631e7..03fd32230 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,10 +1,13 @@ $Log$ +Revision 1.399 1999/10/28 03:20:17 ajc +* Fixed the problem of worker threads waking up prematurely. +* 'QUIT'-terminated sessions now exit properly. Still need to fix code for + sessions which are terminated from another session or by the server. + Revision 1.398 1999/10/27 04:26:58 ajc * Initial hack of worker-thread rearchitecture. Right now it is successfully dispatching worker threads to active client sockets (and to the master - socket too, of course). Removing sessions is currently broken. There is - also a problem with worker threads waking up too quickly when a client - command is entered (race condition?). More cleanup to follow. + socket too, of course). Removing sessions is currently broken. Revision 1.397 1999/10/26 20:20:29 ajc * Removed the auto-reconnect stuff... it was locking the client in an active @@ -1371,4 +1374,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citserver.c b/citadel/citserver.c index cd791e358..0e5c9e908 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -862,13 +862,10 @@ void begin_session(struct CitContext *con) void do_command_loop(void) { char cmdbuf[256]; - lprintf(9, "Hi, I'm do_command_loop() and I have client socket %d\n", - CC->client_socket); - time(&CC->lastcmd); memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */ if (client_gets(cmdbuf) < 1) { - lprintf(3, "Socket is broken, I think.\n"); + lprintf(3, "Client socket is broken. Ending session.\n"); cleanup(EXIT_NULL); } lprintf(5, "citserver[%3d]: %s\n", CC->cs_pid, cmdbuf); @@ -899,6 +896,7 @@ void do_command_loop(void) { else if (!strncasecmp(cmdbuf,"QUIT",4)) { cprintf("%d Goodbye.\n",OK); + cleanup(0); } else if (!strncasecmp(cmdbuf,"LOUT",4)) { diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 0f004f172..367cc7922 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -868,10 +868,7 @@ void worker_thread(void) { */ begin_critical_section(S_I_WANNA_SELECT); - lprintf(9, "Worker thread %2d woke up\n", getpid()); - -SETUP_FD: - FD_ZERO(&readfds); +SETUP_FD: FD_ZERO(&readfds); FD_SET(msock, &readfds); highest = msock; FD_SET(rescan[0], &readfds); @@ -889,10 +886,7 @@ SETUP_FD: } end_critical_section(S_SESSION_TABLE); - lprintf(9, "Thread %2d can wake up on %d different fd's\n", - getpid(), numselect); retval = select(highest + 1, &readfds, NULL, NULL, NULL); - lprintf(9, "select() returned %d\n", retval); /* Now figure out who made this select() unblock. * First, check for an error or exit condition. @@ -907,7 +901,6 @@ SETUP_FD: * on the master socket. */ else if (FD_ISSET(msock, &readfds)) { - lprintf(9, "It's the master socket!\n"); alen = sizeof fsin; ssock = accept(msock, (struct sockaddr *)&fsin, &alen); if (ssock < 0) { @@ -945,7 +938,6 @@ SETUP_FD: * current data. */ else if (FD_ISSET(rescan[0], &readfds)) { - lprintf(9, "rescanning\n"); read(rescan[0], &junk, 1); goto SETUP_FD; } @@ -961,7 +953,7 @@ SETUP_FD: ptr = ptr->next) { if ( (FD_ISSET(ptr->client_socket, &readfds)) && (ptr->state == CON_IDLE) ) { - bind_me = con; + bind_me = ptr; } } if (bind_me != NULL) { @@ -976,8 +968,6 @@ SETUP_FD: /* We're bound to a session, now do *one* command */ if (bind_me != NULL) { - lprintf(9, "Binding thread to session %d\n", - bind_me->client_socket); pthread_setspecific(MyConKey, (void *)bind_me); do_command_loop(); pthread_setspecific(MyConKey, (void *)NULL); -- 2.39.2