* tcp_sockets.c: changed memcpy() to memset() in tcp_connectsock; this was
authorArt Cancro <ajc@citadel.org>
Thu, 20 Apr 2000 02:42:23 +0000 (02:42 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 20 Apr 2000 02:42:23 +0000 (02:42 +0000)
  crashing every session, every time.  (?)
* End the session after displaying robots.txt or nocookies.html, to prevent
  big session logjams when either of these conditions are met

webcit/ChangeLog
webcit/auth.c
webcit/context_loop.c
webcit/tcp_sockets.c
webcit/webcit.c
webcit/webcit.h

index d1b3cf4db002787ee13752ceb219bd8dbdb88ad7..842626b09250d32be4e18fa1250cf7b579beb8e9 100644 (file)
@@ -1,4 +1,10 @@
 $Log$
+Revision 211.15  2000/04/20 02:42:23  ajc
+* tcp_sockets.c: changed memcpy() to memset() in tcp_connectsock; this was
+  crashing every session, every time.  (?)
+* End the session after displaying robots.txt or nocookies.html, to prevent
+  big session logjams when either of these conditions are met
+
 Revision 211.14  2000/04/15 15:43:46  nbryant
 * warning fix for 64-bit compile on ultrasparc. (kids don't try this at home,
   64-bit gcc on sparc is evil)
@@ -422,3 +428,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index ec1ed5bcf2512ca9a31a100515992a2784e2682c..97bd8658a8812e4b2bdb3d34988651898b4fc6fe 100644 (file)
@@ -176,6 +176,17 @@ void do_welcome(void)
 }
 
 
+/*
+ * Disconnect from the Citadel server, and end this WebCit session
+ */
+void end_webcit_session(void) {
+       serv_puts("QUIT");
+       close(WC->serv_sock);
+       WC->serv_sock = (-1);
+       WC->killthis = 1;
+}
+
+
 void do_logout(void)
 {
        char buf[256];
@@ -199,16 +210,11 @@ void do_logout(void)
                "<A HREF=\"javascript:window.close();\">Close window</A>"
                "</CENTER>\n");
        wDumpContent(2);
-       serv_puts("QUIT");
-       close(WC->serv_sock);
-       WC->serv_sock = (-1);
-       WC->killthis = 1;
+       end_webcit_session();
 }
 
 
 
-
-
 /* 
  * validate new users
  */
index 2cdd78088557d6310d3a699126548f46ebfab970..41010072fcfeae4a1963b48f4443f2d98324794b 100644 (file)
@@ -253,12 +253,14 @@ void context_loop(int sock)
         * robots.txt file...
         */
        if (!strncasecmp(buf, "/robots.txt", 11)) {
-               strcpy(req->line, "GET /static/robots.txt HTTP/1.0");
+               strcpy(req->line, "GET /static/robots.txt"
+                               "?force_close_session=yes HTTP/1.0");
        }
 
        /* Do the non-root-cookie check now. */
        else if ( (strcmp(buf, "/")) && (got_cookie == 0)) {
-               strcpy(req->line, "GET /static/nocookies.html HTTP/1.0");
+               strcpy(req->line, "GET /static/nocookies.html"
+                               "?force_close_session=yes HTTP/1.0");
        }
 
 
@@ -302,7 +304,6 @@ void context_loop(int sock)
         */
 
 
-
        /*
         * Bind to the session and perform the transaction
         */
index 1c44f661b48649aa2453547ac7dd55f20a8c78ee..9501a79fb9b7ff88e45e064eb98e314fa9c109f0 100644 (file)
@@ -82,7 +82,7 @@ int tcp_connectsock(char *host, char *service)
        struct sockaddr_in sin;
        int s;
 
-       memcpy(&sin, 0, sizeof(sin));
+       memset(&sin, 0, sizeof(sin));
        sin.sin_family = AF_INET;
 
        pse = getservbyname(service, "tcp");
index 4b3dbd53148079752c2be6587a343b5af99213bf..80e66ed1def2f85e3ec15ee09d7314035b42c991 100644 (file)
 #include <signal.h>
 #include "webcit.h"
 
+/*
+ * String to unset the cookie.
+ * Any date "in the past" will work, so I chose my birthday, right down to
+ * the exact minute.  :)
+ */
+static char *unset = "; expires=28-May-1971 18:10:00 GMT";
 
 void unescape_input(char *buf)
 {
@@ -280,7 +286,6 @@ void urlescputs(char *strbuf)
  */
 void output_headers(int controlcode)
 {
-       static char *unset = "; expires=28-May-1971 18:10:00 GMT";
        char cookie[256];
        int print_standard_html_head = 0;
        int refresh30 = 0;
@@ -300,7 +305,6 @@ void output_headers(int controlcode)
        stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
                        WC->wc_password, WC->wc_roomname);
        if (print_standard_html_head == 2) {
-               wprintf("X-WebCit-Session: close\n");
                wprintf("Set-cookie: webcit=%s\n", unset);
        } else {
                wprintf("Set-cookie: webcit=%s\n", cookie);
@@ -434,6 +438,9 @@ void output_static(char *what)
                }
                fclose(fp);
        }
+       if (!strcasecmp(bstr("force_close_session"), "yes")) {
+               end_webcit_session();
+       }
 }
 
 /*
@@ -682,6 +689,7 @@ void session_loop(struct httprequest *req)
                }
                else {
                        /* tcp socket */
+                       fprintf(stderr, "FIXME tcp conn\n");
                        WC->serv_sock = tcp_connectsock(c_host, c_port);
                }
 
index d986ae60f4912ecd56337899768fec8f6b318f37..bdb0a081d60fda527e0f5107c2270de997305e28 100644 (file)
@@ -1,5 +1,7 @@
 /* $Id$ */
 
+#define TRACE fprintf(stderr, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
+
 #define SLEEPING               180             /* TCP connection timeout */
 #define WEBCIT_TIMEOUT         900             /* WebCit session timeout */
 #define PORT_NUM               2000            /* port number to listen on */
@@ -255,3 +257,4 @@ void mime_parser(char *content,
                    void *cbcontent,                                                                char *cbtype,                                                                   size_t cblength)
 );
 void fmt_date(char *buf, time_t thetime);
+void end_webcit_session(void);