]> code.citadel.org Git - citadel.git/commitdiff
* Attempt to fix the dangling sockets.
authorArt Cancro <ajc@citadel.org>
Sat, 19 May 2001 02:21:40 +0000 (02:21 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 19 May 2001 02:21:40 +0000 (02:21 +0000)
webcit/ChangeLog
webcit/auth.c
webcit/webcit.c

index 57c8caeea37f10af6e318a42f18829badf47a1e4..3db7091efde119fc6b6a511fcac40acba631064b 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 213.12  2001/05/19 02:21:40  ajc
+* Attempt to fix the dangling sockets.
+
 Revision 213.11  2001/05/15 03:22:25  ajc
 * More icon updates and link cleanup type stuff
 
@@ -541,4 +544,3 @@ 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 8149bd44e388f855df3ef2ae72a53f43e18f8172..31f258871110bc192ade82ca55ad757648a0b822 100644 (file)
@@ -152,9 +152,8 @@ void do_welcome(void)
  */
 void end_webcit_session(void) {
        serv_puts("QUIT");
-       close(WC->serv_sock);
-       WC->serv_sock = (-1);
        WC->killthis = 1;
+       /* close() of citadel socket will be done by do_housekeeping() */
 }
 
 
index 5a77602d0d6497abcad42df5ce95937a509bc18b..38c14551cdff0f700b766a4e01eeafe4a1eb855b 100644 (file)
@@ -394,10 +394,10 @@ void check_for_express_messages()
 void output_static(char *what)
 {
        char buf[4096];
-       long thisblock;
        FILE *fp;
        struct stat statbuf;
        off_t bytes;
+       char *bigbuffer;
 
        sprintf(buf, "static/%s", what);
        fp = fopen(buf, "rb");
@@ -425,14 +425,11 @@ void output_static(char *what)
                fprintf(stderr, "Static: %s, %ld bytes\n", what, bytes);
                wprintf("Content-length: %ld\n", (long) bytes);
                wprintf("\n");
-               while (bytes > 0) {
-                       thisblock = sizeof(buf);
-                       if (thisblock > bytes) thisblock = bytes;
-                       fread(buf, thisblock, 1, fp);
-                       write(WC->http_sock, buf, thisblock);
-                       bytes = bytes - thisblock;
-               }
+               bigbuffer = malloc(bytes);
+               fread(bigbuffer, bytes, 1, fp);
                fclose(fp);
+               write(WC->http_sock, bigbuffer, bytes);
+               free(bigbuffer);
        }
        if (!strcasecmp(bstr("force_close_session"), "yes")) {
                end_webcit_session();
@@ -463,13 +460,18 @@ void output_image()
 
                while (bytes > (off_t) 0) {
                        thisblock = (off_t) sizeof(xferbuf);
-                       if (thisblock > bytes)
+                       if (thisblock > bytes) {
                                thisblock = bytes;
+                       }
                        serv_printf("READ %ld|%ld", accomplished, thisblock);
                        serv_gets(buf);
-                       if (buf[0] == '6')
+                       if (buf[0] == '6') {
                                thisblock = extract_long(&buf[4], 0);
-                       serv_read(xferbuf, (int) thisblock);
+                               serv_read(xferbuf, (int) thisblock);
+                       }
+                       else {
+                               memset(xferbuf, 0, thisblock);
+                       }
                        write(WC->http_sock, xferbuf, thisblock);
                        bytes = bytes - thisblock;
                        accomplished = accomplished + thisblock;