*** empty log message ***
authorMatthew Mondor <mmondor@pulsar-zone.net>
Tue, 22 Aug 2006 10:12:54 +0000 (10:12 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Tue, 22 Aug 2006 10:12:54 +0000 (10:12 +0000)
mmsoftware/js/js-sh/app/httpd/httpd.js

index 2e2f5e3..52cf938 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: httpd.js,v 1.36 2006/08/20 20:32:42 mmondor Exp $ */
+/* $Id: httpd.js,v 1.37 2006/08/22 10:12:54 mmondor Exp $ */
 
 /*
  * Copyright (c) 2005-2006, Matthew Mondor
@@ -76,7 +76,7 @@
  * Server identification
  */
 const SERVER_VERSION = 'mmondor_js_httpd/0.1.0 (NetBSD)';
-const SERVER_CVSID = '$Id: httpd.js,v 1.36 2006/08/20 20:32:42 mmondor Exp $';
+const SERVER_CVSID = '$Id: httpd.js,v 1.37 2006/08/22 10:12:54 mmondor Exp $';
 
 
 
@@ -647,9 +647,6 @@ function state_http_transfer_file(time)
                        this.transfer_state = TSTATE_WRITE;
                } catch (x) {
                        stat = PSTAT_CLOSE_ERROR;
-                       try {
-                               this.transfer_src.close();
-                       } catch (x) {}
                }
        }
        if (this.transfer_state == TSTATE_WRITE) {
@@ -664,13 +661,16 @@ function state_http_transfer_file(time)
                        } else if (this.berror != this.BEAGAIN)
                                stat = PSTAT_CLOSE_ERROR;
                }
-               if (stat != PSTAT_CONTINUE) {
-                       try {
-                               this.transfer_src.close();
-                       } catch (x) {}
-               }
        }
 
+       /* Currently redundant unless we supported Keep-Alive
+       if (stat != PSTAT_CONTINUE) {
+               try {
+                       this.transfer_src.close();
+               } catch (x) {}
+       }
+       */
+
        return stat;
 }
 
@@ -845,6 +845,8 @@ FD.prototype.parseQuery = function(time)
        /*
         * Fill in associative array with any GET-style supplied
         * variables (as part of the URL).  We want this even for POST method.
+        * XXX We might need to account for vars without content, and for %xx
+        * characters...
         */
        if ((i = this.http_path.lastIndexOf('?')) != -1) {
                var v;
@@ -955,6 +957,7 @@ FD.prototype.httpRespond = function(time)
         * 2) If file successfully opened, upload it to client.
         * 3) If to forward request to appserver, perform the following:
         *
+        * XXX Rewrite this
         * 1) Verify if session cookie provided.  If not, invoke appserver
         *    to create a new session and send new session cookie to client,
         *    redirecting it to the same path after a few seconds.  Record
@@ -1076,7 +1079,7 @@ FD.prototype.httpRespond = function(time)
        if (appserv_match) {
                http_error(this, 500, 'Internal Server Error',
                    'You have requested an application server handled path ' +
-                   'which cannot be handled at this time.  Please try ' +
+                   'which cannot be processed at this time.  Please try ' +
                    'again later.');
                return PSTAT_CLOSE_SUCCESS;
        }
@@ -1298,6 +1301,12 @@ function state_connect_appserv(time)
                 * takes place.
                 * Hence we seem to need some general purpose FD based
                 * semaphore system...
+                * XXX Let's resume this...  we need states:
+                * WAIT_CONNECTION (per-sid, must also have create/load
+                * command and if create, be able to return to client the
+                * new SID)
+                * WAIT_SID (per-client)
+                * TRANSFER_SID (one client at a time)
                 */
                http_error(this.client_fd, 500, 'Internal Server Error',
                    'There was an error establishing connection to an ' +
@@ -1853,6 +1862,15 @@ function main() {
                                         * them to return a 500 error
                                         */
                                }
+                               /*
+                                * If there were any static file uploads in
+                                * progress, close source file's descriptor
+                                */
+                               if (efd.transfer_src != undefined) {
+                                       try {
+                                               efd.transfer_src.close();
+                                       } catch (x) {}
+                               }
                                climits.remove(efd);
                                pollset.remove(efd);
                        }