Author: toad
Date: 2008-03-05 16:57:21 +0000 (Wed, 05 Mar 2008)
New Revision: 18373

Modified:
   trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
   trunk/freenet/src/freenet/clients/http/ToadletContainer.java
   trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
Log:
Don't use persistent connections by default. Add a config to change this.
This should significantly speed up fproxy when freenet is first installed, 
because it will go from 2 parallel conns to 8 parallel conns.

Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java     
2008-03-05 13:14:26 UTC (rev 18372)
+++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java     
2008-03-05 16:57:21 UTC (rev 18373)
@@ -73,6 +73,7 @@
        private final Executor executor;
        private boolean doRobots;
        public BookmarkManager bookmarkManager;
+       private boolean enablePersistentConnections;

        static boolean isPanicButtonToBeShown;
        public static final int DEFAULT_FPROXY_PORT = 8888;
@@ -346,6 +347,29 @@
                                        else    
SimpleToadletServer.isPanicButtonToBeShown = value;
                                }
                });
+               
+               // This is OFF BY DEFAULT because for example firefox has a 
limit of 2 persistent 
+               // connections per server, but 8 non-persistent connections per 
server. We need 8 conns
+               // more than we need the efficiency gain of reusing connections 
- especially on first
+               // install.
+               
+               fproxyConfig.register("enablePersistentConnections", false, 
configItemOrder++, false, false, 
"SimpleToadletServer.enablePersistentConnections", 
"SimpleToadletServer.enablePersistentConnectionsLong",
+                               new BooleanCallback() {
+
+                                       public boolean get() {
+                                               
synchronized(SimpleToadletServer.this) {
+                                                       return 
enablePersistentConnections;
+                                               }
+                                       }
+
+                                       public void set(boolean val) throws 
InvalidConfigValueException {
+                                               
synchronized(SimpleToadletServer.this) {
+                                                       
enablePersistentConnections = val;
+                                               }
+                                       }
+               });
+               enablePersistentConnections = 
fproxyConfig.getBoolean("enablePersistentConnections");
+                               
                fproxyConfig.register("allowedHosts", 
"127.0.0.1,0:0:0:0:0:0:0:1", configItemOrder++, true, true, 
"SimpleToadletServer.allowedHosts", "SimpleToadletServer.allowedHostsLong",
                                new FProxyAllowedHostsCallback());
                fproxyConfig.register("allowedHostsFullAccess", 
"127.0.0.1,0:0:0:0:0:0:0:1", configItemOrder++, true, true, 
"SimpleToadletServer.allowedFullAccess", 
@@ -619,5 +643,9 @@
                if(bookmarkManager == null) return new FreenetURI[0];
                return bookmarkManager.getBookmarkURIs();
        }
+
+       public boolean enablePersistentConnections() {
+               return enablePersistentConnections;
+       }

 }

Modified: trunk/freenet/src/freenet/clients/http/ToadletContainer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContainer.java        
2008-03-05 13:14:26 UTC (rev 18372)
+++ trunk/freenet/src/freenet/clients/http/ToadletContainer.java        
2008-03-05 16:57:21 UTC (rev 18373)
@@ -44,4 +44,6 @@
        public boolean doRobots();

        public HTMLNode addFormChild(HTMLNode parentNode, String target, String 
name);
+
+       public boolean enablePersistentConnections();
 }

Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java      
2008-03-05 13:14:26 UTC (rev 18372)
+++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java      
2008-03-05 16:57:21 UTC (rev 18373)
@@ -272,7 +272,7 @@
                                        headers.put(before, after);
                                }

-                               boolean disconnect = 
shouldDisconnectAfterHandled(split[2].equals("HTTP/1.0"), headers);
+                               boolean disconnect = 
shouldDisconnectAfterHandled(split[2].equals("HTTP/1.0"), headers) || 
!container.enablePersistentConnections();

                                ToadletContextImpl ctx = new 
ToadletContextImpl(sock, headers, bf, pageMaker, container);
                                ctx.shouldDisconnect = disconnect;

Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-03-05 
13:14:26 UTC (rev 18372)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-03-05 
16:57:21 UTC (rev 18373)
@@ -969,6 +969,8 @@
 StatisticsToadlet.authBytes=Connection setup: ${total} output
 StatisticsToadlet.bandwidthTitle=Bandwidth
 StatisticsToadlet.cpus=Available CPUs: ${count}
+StatisticsToadlet.enablePersistentConnections=Enable persistent HTTP 
connections? (Read detailed description)
+StatisticsToadlet.enablePersistentConnections=Don't enable this unless your 
browser is configured to use lots of connections even if they are persistent.
 StatisticsToadlet.fullTitle=Statistics for ${name}
 StatisticsToadlet.getLogs=Get latest node's logfile
 StatisticsToadlet.inputRate=Input Rate: ${rate}/sec (of ${max})


Reply via email to