+ }
+ else {
+ lprintf(7, "citserver: New client socket %d\n",
+ ssock);
+
+ /* New context will be created already set up
+ * in the CON_EXECUTING state.
+ */
+ con = CreateNewContext();
+
+ /* Assign our new socket number to it. */
+ con->client_socket = ssock;
+
+ /* Set the SO_REUSEADDR socket option */
+ i = 1;
+ setsockopt(ssock, SOL_SOCKET, SO_REUSEADDR,
+ &i, sizeof(i));
+
+ pthread_setspecific(MyConKey, (void *)con);
+ begin_session(con);
+ /* do_command_loop(); */
+ pthread_setspecific(MyConKey, (void *)NULL);
+ con->state = CON_IDLE;
+ goto SETUP_FD;
+ }
+ }
+
+ /* If the rescan pipe went active, someone is telling this
+ * thread that the &readfds needs to be refreshed with more
+ * current data.
+ */
+ else if (FD_ISSET(rescan[0], &readfds)) {
+ lprintf(9, "rescanning\n");
+ read(rescan[0], &junk, 1);
+ goto SETUP_FD;
+ }
+
+ /* It must be a client socket. Find a context that has data
+ * waiting on its socket *and* is in the CON_IDLE state.
+ */
+ else {
+ bind_me = NULL;
+ begin_critical_section(S_SESSION_TABLE);
+ for (ptr = ContextList;
+ ( (ptr != NULL) && (bind_me == NULL) );
+ ptr = ptr->next) {
+ if ( (FD_ISSET(ptr->client_socket, &readfds))
+ && (ptr->state == CON_IDLE) ) {
+ bind_me = con;