[Gd-chatter] r11257 - in trunk/libraries/network/koala: config sources/koala

hannes at gwydiondylan.org hannes at gwydiondylan.org
Wed Apr 11 23:36:43 CEST 2007


Author: hannes
Date: Wed Apr 11 23:36:40 2007
New Revision: 11257

Modified:
   trunk/libraries/network/koala/config/koala-config.xml
   trunk/libraries/network/koala/sources/koala/config.dylan
   trunk/libraries/network/koala/sources/koala/server.dylan
   trunk/libraries/network/koala/sources/koala/vhost.dylan
Log:
Job: koala
implement <listen-ip value="ip" /> config argument

this is needed to run several different web applications on a
server with multiple IPs, like leibniz :)


Modified: trunk/libraries/network/koala/config/koala-config.xml
==============================================================================
Binary files. No diff available.

Modified: trunk/libraries/network/koala/sources/koala/config.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/config.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/config.dylan	Wed Apr 11 23:36:40 2007
@@ -205,6 +205,17 @@
 end;
 
 define method process-config-element
+    (node :: xml$<element>, name == #"listen-ip")
+  let attr = get-attr(node, #"value");
+  if (attr)
+    vhost-ip(active-vhost()) := attr;
+    log-info("VHost '%s': listen ip = %s", vhost-name(active-vhost()), attr);
+  else
+    warn("Invalid <listen-ip> spec.  The 'value' attribute must be specified.");
+  end;
+end;
+
+define method process-config-element
     (node :: xml$<element>, name == #"port")
   let attr = get-attr(node, #"value");
   if (attr)

Modified: trunk/libraries/network/koala/sources/koala/server.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/server.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/server.dylan	Wed Apr 11 23:36:40 2007
@@ -44,8 +44,6 @@
   slot max-listeners :: <integer> = 1;
   slot request-class :: subclass(<basic-request>) = <basic-request>;
 
-  //---TODO: Need to define an API for extending this, and then have a
-  // request-method-definer macro..
   //---TODO: response for unsupported-request-method-error MUST include
   // Allow: field...  Need an API for making sure that happens.
   // RFC 2616, 5.1.1
@@ -68,7 +66,6 @@
   slot connections-accepted :: <integer> = 0; // Connections accepted
   constant slot user-agent-stats :: <string-table> = make(<string-table>);
   constant class slot startup-date :: <date> = current-date();
-  slot listen-ip :: false-or(<string>) = #f;
 end;
 
 define sealed method make
@@ -117,6 +114,8 @@
     required-init-keyword: server:;
   constant slot listener-port :: <integer>,
     required-init-keyword: port:;
+  constant slot listener-host :: false-or(<string>),
+    required-init-keyword: host:;
   constant slot listener-thread :: <thread>,
     required-init-keyword: thread:;
   slot listener-socket :: <server-socket>,
@@ -259,7 +258,8 @@
     else
       // temporary code...
       let port = ports[0];
-      while (start-http-listener(*server*, port))
+      let ip = vhost-ip($default-virtual-host);
+      while (start-http-listener(*server*, port, ip))
         *server-running?* := #t;
       end;
       // Apparently when the main thread dies in a FunDev Dylan application
@@ -354,7 +354,7 @@
   end;
 end join-clients;
 
-define function start-http-listener (server :: <server>, port :: <integer>)
+define function start-http-listener (server :: <server>, port :: <integer>, ip :: <string>)
    => (started? :: <boolean>)
   let server-lock = server.server-lock;
   let listener = #f;
@@ -376,13 +376,17 @@
     let listeners = server.server-listeners;
     when (listeners.size < server.max-listeners)
       log-debug("Creating a new listener thread.");
-      let socket = make(<server-socket>, port: port);
+      let socket = make(<server-socket>, host: ip, port: port);
       let thread = make(<thread>,
                         name: format-to-string("HTTP Listener #%s/%d", *next-listener-id*, port),
                         function: run-listener-top-level);
       wrapping-inc!(*next-listener-id*);
       listener := make(<listener>,
-                       server: server, port: port, socket: socket, thread: thread);
+                       server: server,
+                       port: port,
+                       socket: socket,
+                       host: ip,
+                       thread: thread);
       add!(server.server-listeners, listener);
       started? := #t
     end;
@@ -406,7 +410,9 @@
                          ~listener.listener-exit-requested? &
                          listeners.size <= server.max-listeners)
                      listener.listener-socket
-                       := make(<server-socket>, port: listener.listener-port);
+                       := make(<server-socket>,
+                               host: listener.listener-host,
+                               port: listener.listener-port);
                      inc!(listener.total-restarts);
                      #t
                    end;

Modified: trunk/libraries/network/koala/sources/koala/vhost.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/vhost.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/vhost.dylan	Wed Apr 11 23:36:40 2007
@@ -92,6 +92,8 @@
   //       port.
   slot vhost-port :: <integer> = 80;
 
+  slot vhost-ip :: <string> = "0.0.0.0";
+
   // List of <directory-spec> objects that determine how documents in
   // different directories are treated.  These are searched in order,
   // and the first one to match the requested URL is used.  Items are



More information about the chatter mailing list