Oops, it appears I went a bit too fast: 

mainParseOptions() has to be called before parseConfigFile() indeed, because 
of the -f option to specify an alternate configuration file, but still: the 
handling of the -V option was broken.

Here's a second patch (disregard the first one) fixing all this...

...hopefully ;)

On Friday 15 December 2006 22:43, me, myself, I wrote:
> Hi guys!
>
>
> This afternoon I was testing Squid3 (needed the ICAP-client functionality)
> and it wouldn't start as a virtual-host httpd-accelerator (the -V option on
> the command-line), saying "FATAL: No http_port specified" even though it
> really was specified in the configuration file...
>
> I found out this is because mainParseOptions() is called _before_
> parseConfigFile() in main.cc, so of course Config.Sockaddr.http is NULL
> when handling the -V option. The attached patch fixes this.
>
> Patching that was no big deal, but it's better when it works out of the box
> ;) So here you are, my tiny contribution to the great Squid!
>
>
> Keep up the good work,

-- 
Sébastien Raveau
computer and network security student
head of the hawKeye network monitor project
http://hawkeye.sourceforge.net/
--- main.cc.orig	2006-12-15 22:01:43.000000000 +0100
+++ main.cc	2006-12-16 17:43:23.000000000 +0100
@@ -93,6 +93,7 @@
 static int opt_parse_cfg_only = 0;
 static char *opt_syslog_facility = NULL;
 static int icpPortNumOverride = 1;	/* Want to detect "-u 0" */
+static int virtualHostAccel = 0;	/* Want to detect "-V" */
 static int configured_once = 0;
 #if MALLOC_DBG
 static int malloc_debug_level = 0;
@@ -292,21 +293,8 @@
             break;
 
         case 'V':
-
-            if (Config.Sockaddr.http)
-                Config.Sockaddr.http->vhost = 1;
-
-#if USE_SSL
-
-            else if (Config.Sockaddr.https)
-                Config.Sockaddr.https->http.vhost = 1;
-
-#endif
-
-            else
-                fatal("No http_port specified\n");
-
-            break;
+	    virtualHostAccel = 1;
+	    break;
 
         case 'X':
             /* force full debugging */
@@ -1226,6 +1214,18 @@
         if (checkRunningPid())
             exit(1);
 
+    if (virtualHostAccel)
+    {
+        if (Config.Sockaddr.http)
+            Config.Sockaddr.http->vhost = 1;
+#if USE_SSL
+        else if (Config.Sockaddr.https)
+            Config.Sockaddr.https->http.vhost = 1;
+#endif
+       else
+            fatal("No http_port specified\n");
+    }
+
 #if TEST_ACCESS
 
     comm_init();

Attachment: pgp3hjOyAzE2L.pgp
Description: PGP signature

Reply via email to