changeset 1534:606f06850b83

* include/httpd.h: * src/init.cxx: * src/httpd.c: * src/init.cxx: Added option to enable auto-starting of HTTPD. This is set by default so the current behaviour is retained. When this is disabled the application has to call cyg_httpd_startup() to get the server going.
author nickg
date Tue, 09 Mar 2004 10:33:24 +0000
parents 89eafd905d8d
children 00ed8504e595
files packages/net/httpd/current/ChangeLog packages/net/httpd/current/cdl/httpd.cdl packages/net/httpd/current/include/httpd.h packages/net/httpd/current/src/httpd.c packages/net/httpd/current/src/init.cxx
diffstat 5 files changed, 43 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/packages/net/httpd/current/ChangeLog
+++ b/packages/net/httpd/current/ChangeLog
@@ -1,6 +1,17 @@
+2004-03-09  Nick Garnett  <nickg@calivar.com>
+
+	* include/httpd.h: 
+	* src/init.cxx: 
+	* src/httpd.c: 
+	* src/init.cxx:
+	Added option to enable auto-starting of HTTPD. This is set by
+	default so the current behaviour is retained. When this is
+	disabled the application has to call cyg_httpd_startup() to get
+	the server going.
+
 2004-02-23  Jeff Duncan  <jeffd@magtek.com>
 
-        * src/httpd.c (cyg_httpd_server): Fix http header by adding
+	* src/httpd.c (cyg_httpd_server): Fix http header by adding
           newline after server name.
 
 2003-10-21  Eric Doenges <Eric.Doenges@DynaPel.com>
--- a/packages/net/httpd/current/cdl/httpd.cdl
+++ b/packages/net/httpd/current/cdl/httpd.cdl
@@ -70,7 +70,7 @@ cdl_package CYGPKG_HTTPD {
 
     compile httpd.c 
     compile -library=libextras.a init.cxx
-    
+
     cdl_option CYGNUM_HTTPD_SERVER_PORT {
         display "HTTP port"
         flavor   data
@@ -131,6 +131,15 @@ cdl_package CYGPKG_HTTPD {
                      long URLs or have very complex forms, this should be increased."
     }
 
+    cdl_option CYGNUM_HTTPD_SERVER_AUTO_START {
+       display  "Autostart HTTPD"
+       default_value 1
+       description  "This option causes the HTTP Daemon to be started
+                     automatically during system initialization. If this option
+                     is not set then the application must start the daemon
+                     explicitly by calling cyg_httpd_startup()."
+    }
+
     cdl_option CYGNUM_HTTPD_SERVER_DELAY {
         display "HTTPD server startup delay"
         flavor data
--- a/packages/net/httpd/current/include/httpd.h
+++ b/packages/net/httpd/current/include/httpd.h
@@ -64,6 +64,16 @@
 #include <stdio.h>
 
 /* ================================================================= */
+/* Start daemon explicitly
+ */
+
+#ifndef CYGNUM_HTTPD_SERVER_AUTO_START
+
+__externC void cyg_httpd_startup(void);
+
+#endif
+
+/* ================================================================= */
 /* Lookup Table
  *
  * 
--- a/packages/net/httpd/current/src/httpd.c
+++ b/packages/net/httpd/current/src/httpd.c
@@ -237,6 +237,7 @@ static void cyg_httpd_process( int clien
       
         if( match( filename, entry->pattern ) )
         {
+            HTTPD_DIAG("calling %08x: %s\n", entry, entry->pattern);
             if( (success = entry->handler( client, filename, formdata, entry->arg )) )
                 break;
         }
@@ -250,7 +251,10 @@ static void cyg_httpd_process( int clien
      * some filesystem, somewhere.
      */
     if( !success )
+    {
+        HTTPD_DIAG("Not found %s\n",filename);
         cyg_httpd_send_html( client, NULL, NULL, cyg_httpd_not_found );
+    }
 
     fclose(client);
 }
@@ -382,7 +386,9 @@ static void cyg_httpd_init(cyg_addrword_
 /* System initializer
  *
  * This is called from the static constructor in init.cxx. It spawns
- * the main server thread and makes it ready to run.
+ * the main server thread and makes it ready to run. It can also be
+ * called explicitly by the application if the auto start option is
+ * disabled.
  */
 
 __externC void cyg_httpd_startup(void)
--- a/packages/net/httpd/current/src/init.cxx
+++ b/packages/net/httpd/current/src/init.cxx
@@ -57,6 +57,8 @@
 #include <pkgconf/isoinfra.h>
 #include <pkgconf/httpd.h>
 
+#ifdef CYGNUM_HTTPD_SERVER_AUTO_START
+
 #include <cyg/infra/cyg_trac.h>        // tracing macros
 #include <cyg/infra/cyg_ass.h>         // assertion macros
 
@@ -89,5 +91,7 @@ Cyg_Httpd_Init_Class::Cyg_Httpd_Init_Cla
     cyg_httpd_startup();
 }
 
+#endif // CYGNUM_HTTPD_SERVER_AUTO_START
+
 /* ----------------------------------------------------------------- */
 /* end of httpd.c                                                    */