couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1055592 - in /couchdb/trunk: etc/couchdb/default.ini.tpl.in etc/couchdb/local.ini src/couchdb/couch_httpd.erl
Date Wed, 05 Jan 2011 19:26:15 GMT
Author: fdmanana
Date: Wed Jan  5 19:26:14 2011
New Revision: 1055592

URL: http://svn.apache.org/viewvc?rev=1055592&view=rev
Log:
Added [httpd] socket_options and server_options

Part of this patch (the server_options parameter) is a contribution from Randall Leeds.
Closes COUCHDB-1008


Modified:
    couchdb/trunk/etc/couchdb/default.ini.tpl.in
    couchdb/trunk/etc/couchdb/local.ini
    couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/etc/couchdb/default.ini.tpl.in
URL: http://svn.apache.org/viewvc/couchdb/trunk/etc/couchdb/default.ini.tpl.in?rev=1055592&r1=1055591&r2=1055592&view=diff
==============================================================================
--- couchdb/trunk/etc/couchdb/default.ini.tpl.in (original)
+++ couchdb/trunk/etc/couchdb/default.ini.tpl.in Wed Jan  5 19:26:14 2011
@@ -20,6 +20,10 @@ default_handler = {couch_httpd_db, handl
 secure_rewrites = true
 vhost_global_handlers = _utils, _uuids, _session, _oauth, _users
 allow_jsonp = false
+; Options for the MochiWeb HTTP server.
+;server_options = [{backlog, 128}, {acceptor_pool_size, 16}]
+; For more socket options, consult Erlang's module 'inet' man page.
+;socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
 
 [ssl]
 port = 6984

Modified: couchdb/trunk/etc/couchdb/local.ini
URL: http://svn.apache.org/viewvc/couchdb/trunk/etc/couchdb/local.ini?rev=1055592&r1=1055591&r2=1055592&view=diff
==============================================================================
--- couchdb/trunk/etc/couchdb/local.ini (original)
+++ couchdb/trunk/etc/couchdb/local.ini Wed Jan  5 19:26:14 2011
@@ -10,6 +10,11 @@
 [httpd]
 ;port = 5984
 ;bind_address = 127.0.0.1
+; Options for the MochiWeb HTTP server.
+;server_options = [{backlog, 128}, {acceptor_pool_size, 16}]
+; For more socket options, consult Erlang's module 'inet' man page.
+;socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
+
 ; Uncomment next line to trigger basic-auth popup on unauthorized requests.
 ;WWW-Authenticate = Basic realm="administrator"
 

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=1055592&r1=1055591&r2=1055592&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Wed Jan  5 19:26:14 2011
@@ -57,8 +57,6 @@ start_link(Name, Options) ->
     % will restart us and then we will pick up the new settings.
 
     BindAddress = couch_config:get("httpd", "bind_address", any),
-    NoDelay = "true" == couch_config:get("httpd", "nodelay", "false"),
-
     DefaultSpec = "{couch_httpd_db, handle_request}",
     DefaultFun = make_arity_1_fun(
         couch_config:get("httpd", "default_handler", DefaultSpec)
@@ -82,7 +80,17 @@ start_link(Name, Options) ->
     UrlHandlers = dict:from_list(UrlHandlersList),
     DbUrlHandlers = dict:from_list(DbUrlHandlersList),
     DesignUrlHandlers = dict:from_list(DesignUrlHandlersList),
+    {ok, ServerOptions} = couch_util:parse_term(
+        couch_config:get("httpd", "server_options", "[]")),
+    {ok, SocketOptions} = couch_util:parse_term(
+        couch_config:get("httpd", "socket_options", "[]")),
     Loop = fun(Req)->
+        case SocketOptions of
+        [] ->
+            ok;
+        _ ->
+            ok = mochiweb_socket:setopts(Req:get(socket), SocketOptions)
+        end,
         apply(?MODULE, handle_request, [
             Req, DefaultFun, UrlHandlers, DbUrlHandlers, DesignUrlHandlers
         ])
@@ -90,11 +98,10 @@ start_link(Name, Options) ->
 
     % and off we go
 
-    {ok, Pid} = case mochiweb_http:start(Options ++ [
+    {ok, Pid} = case mochiweb_http:start(Options ++ ServerOptions ++ [
         {loop, Loop},
         {name, Name},
-        {ip, BindAddress},
-        {nodelay,NoDelay}
+        {ip, BindAddress}
     ]) of
     {ok, MochiPid} -> {ok, MochiPid};
     {error, Reason} ->
@@ -109,6 +116,10 @@ start_link(Name, Options) ->
             ?MODULE:stop();
         ("httpd", "default_handler") ->
             ?MODULE:stop();
+        ("httpd", "server_options") ->
+            ?MODULE:stop();
+        ("httpd", "socket_options") ->
+            ?MODULE:stop();
         ("httpd_global_handlers", _) ->
             ?MODULE:stop();
         ("httpd_db_handlers", _) ->



Mime
View raw message