$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
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
-
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);
else if (!strncasecmp(cmdbuf,"QUIT",4)) {
cprintf("%d Goodbye.\n",OK);
+ cleanup(0);
}
else if (!strncasecmp(cmdbuf,"LOUT",4)) {
*/
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);
}
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.
* 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) {
* current data.
*/
else if (FD_ISSET(rescan[0], &readfds)) {
- lprintf(9, "rescanning\n");
read(rescan[0], &junk, 1);
goto 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) {
/* 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);