we still have a problem
authorArt Cancro <ajc@citadel.org>
Mon, 30 Nov 1998 04:25:20 +0000 (04:25 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 30 Nov 1998 04:25:20 +0000 (04:25 +0000)
webcit/auth.c
webcit/context_loop.c
webcit/mainmenu.c
webcit/tcp_sockets.c
webcit/webcit.c
webcit/webcit.h
webcit/webserver.c

index 9b2cba50fc0e8ccaf458a08608751b86a0baf1a8..ffe8534ce8899321a899d08b009e26ee45895d07 100644 (file)
@@ -51,9 +51,9 @@ void output_frameset() {
        output_headers();
 
        wprintf("<HTML><HEAD><TITLE>FrameSet</TITLE></HEAD>\n");
-       wprintf("<FRAMESET cols=\"20%, 80%\">\n");
-       wprintf("    <FRAME name=\"left\" src=\"/static/velma.gif\">\n");
-       wprintf("    <FRAME name=\"right\" src=\"/display_main_menu\">\n");
+       wprintf("<FRAMESET cols=\"15%, 80%\">\n");
+       wprintf("  <FRAME name=\"left\" src=\"/static/velma.gif\">\n");
+       wprintf("  <FRAME name=\"right\" src=\"/display_main_menu\">\n");
        wprintf("<NOFRAMES>\n");
        wprintf("Your browser doesn't support frames.<BR>\n");
        wprintf("This site uses frames.<BR>\n");
index bcf5c77117644e37b6c844a7b42b33ee5a9681c9..b24c11229f775c54c308e76cc0cc4c4b9849230f 100644 (file)
@@ -96,6 +96,8 @@ void *context_loop(int *socknumptr) {
 
        sock = *socknumptr;
 
+       printf("Reading request from socket %d\n", sock);
+
        /*
         * Find out what it is that the web browser is asking for
         */
@@ -154,22 +156,32 @@ void *context_loop(int *socknumptr) {
                        }
                }
 
-       /* 
-        * Send the request to the appropriate session
+       /*
+        * Grab a lock on the session, so other threads don't try to access
+        * the pipes at the same time.
         */
+       printf("Locking...\n");
        pthread_mutex_lock(&TheSession->critter);
+
+       /* 
+        * Send the request to the appropriate session...
+        */
+       printf("   Writing %d lines of command\n", num_lines);
+       printf("%s\n", &req[0][0]);
        for (a=0; a<num_lines; ++a) {
                write(TheSession->inpipe[1], &req[a][0], strlen(&req[a][0]));
                write(TheSession->inpipe[1], "\n", 1);
                }
+       printf("   Writing %d bytes of content\n", ContentLength);
        while (ContentLength--) {
                read(sock, buf, 1);
                write(TheSession->inpipe[1], buf, 1);
                }
 
        /*
-        * ...and get the response (FIX for non-text)
+        * ...and get the response.
         */
+       printf("   Reading response\n");
        ContentLength = 0;
        do {
                gets0(TheSession->outpipe[0], buf);
@@ -179,18 +191,28 @@ void *context_loop(int *socknumptr) {
                        ContentLength = atoi(&buf[16]);
                } while (strlen(buf) > 0);
 
+       printf("   Reading %d bytes of content\n");
        while(ContentLength--) {
                read(TheSession->outpipe[0], buf, 1);
                write(sock, buf, 1);
                }
 
-       pthread_mutex_unlock(&TheSession->critter);
-
        /*
         * Now our HTTP connection is done.  It would be relatively easy
         * to support HTTP/1.1 "persistent" connections by looping back to
-        * the top of this function.  For now, we'll just exit.
+        * the top of this function.  For now, we'll just close.
         */
+       printf("   Closing socket\n");
        close(sock);
+
+       /*
+        * Let go of the lock
+        */
+       printf("Unlocking.\n");
+       pthread_mutex_unlock(&TheSession->critter);
+
+       /*
+        * The thread handling this HTTP connection is now finished.
+        */
        pthread_exit(NULL);
        }
index 60f654fe433643d7ea650735ebe997e7b57c226d..64ac83f56b7ab3ee21cf5b85b85da4ac7eb28d09 100644 (file)
@@ -81,6 +81,6 @@ void display_main_menu() {
        output_headers();
        wprintf("<HTML><HEAD><TITLE>WebCit main menu</TITLE></HEAD><BODY>\n");
        embed_main_menu();
-       printf("</BODY></HTML>\n");
+       wprintf("</BODY></HTML>\n");
        wDumpContent();
        }
index c121c3bd42c1e82bff3bafa53e2f987228f4202a..9771fec8f75f2e03847e0e32f4787f897b559ab8 100644 (file)
@@ -148,7 +148,7 @@ char strbuf[]; {
                strbuf[len++] = ch;
                } while((ch!=10)&&(ch!=13)&&(ch!=0)&&(len<255));
        strbuf[len-1] = 0;
-       fprintf(stderr, ">%s\n", strbuf);
+       /* fprintf(stderr, ">%s\n", strbuf); */
        }
 
 
@@ -222,7 +222,7 @@ void serv_printf(const char *format, ...) {
 
        strcat(buf, "\n");
        serv_write(buf, strlen(buf));
-       fprintf(stderr, "<%s", buf);
+       /* fprintf(stderr, "<%s", buf); */
        }
 
 
index 68385a529d759417af4d578d4c142df92200c6fa..1f702ce4fbea40a3a56587676f5be0c6933a364c 100644 (file)
@@ -99,8 +99,6 @@ FOUNDIT:      ptr = up;
 
                up = ptr;
                ++up;
-
-               fprintf(stderr, "%s=%s\n", u->url_key, u->url_data);
                }
 DONE:
        }
@@ -363,13 +361,9 @@ void session_loop() {
        strcpy(c_roomname, "");
 
        getz(cmd);
-       fprintf(stderr, "\nCmd: %s\n", cmd);
-       fflush(stderr);
 
        do {
                getz(buf);
-               fprintf(stderr, "Buf: %s\n", buf);
-               fflush(stderr);
 
                if (!strncasecmp(buf, "Cookie: wc_host=", 16))
                        strcpy(c_host, &buf[16]);
@@ -394,7 +388,6 @@ void session_loop() {
                content = malloc(ContentLength+1);
                fread(content, ContentLength, 1, stdin);
                content[ContentLength] = 0;
-               fprintf(stderr, "CONTENT:\n%s\n", content);
                addurls(content);
                }
        else {
index b3a7cb29980b0042f0c5271c68f1f58f63cab5c7..86699398513b3927ec01d8e0f9a72a0f6a10aafd 100644 (file)
@@ -1,5 +1,5 @@
 #define SLEEPING       180                     /* TCP connection timeout */
-#define PORT_NUM       32763                   /* port number to listen on */
+#define PORT_NUM       32767                   /* port number to listen on */
 #define SERVER         "WebCit v2.0 (Velma)"   /* who's in da house */
 #define DEVELOPER_ID   0
 #define CLIENT_ID      4
index 140c2ee23de14eacaf9b20acf78b028a6b6ebdfa..7e350efafa4c850d66a30799c5ecb2e99f11b904 100644 (file)
@@ -37,6 +37,7 @@ int ig_tcp_server(int port_number, int queue_len)
 {
        struct sockaddr_in sin;
        int s, i;
+       struct linger WebLinger = { 1, 9000 };
 
        memset(&sin, 0, sizeof(sin));
        sin.sin_family = AF_INET;
@@ -56,9 +57,10 @@ int ig_tcp_server(int port_number, int queue_len)
                exit(errno);
                }
 
-       /* Set the SO_REUSEADDR socket option, because it makes sense. */
+       /* Set some socket options that make sense. */
        i = 1;
        setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));
+       setsockopt(s, SOL_SOCKET, SO_LINGER, &WebLinger, sizeof(WebLinger));
 
        if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
                printf("webcit: Can't bind: %s\n", strerror(errno));