aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS13
-rw-r--r--brep/database.cxx15
-rw-r--r--brep/options.cli7
-rw-r--r--etc/brep-module.conf4
-rw-r--r--web/apache/service20
-rw-r--r--web/apache/service.cxx8
-rw-r--r--web/apache/service.txx2
7 files changed, 46 insertions, 23 deletions
diff --git a/NEWS b/NEWS
index d384f21..7a788df 100644
--- a/NEWS
+++ b/NEWS
@@ -4,8 +4,15 @@ Version 0.3.0
Apache2 server. The configuration can be specified at the Apache2 root,
VistualHost, and Location levels.
- * Add support for custom web page logo and menu entries. See comments in
- the etc/brep-module.conf file for details.
+ * Support for custom web page logo and menu entries. See comments in the
+ etc/brep-module.conf file for details.
+
+ * Ability to specify the maximum number of concurrent database connections
+ per web server process. See comments in the etc/brep-module.conf file for
+ details.
+
+ * Ability to specify the maximum number of times to retry database
+ transactions. See comments in the etc/brep-module.conf file for details.
* Display SHA256 package checksum on the package version details pages.
@@ -20,7 +27,7 @@ Version 0.3.0
* Remove a DROP FUNCTION statement that caused an error on older PostgreSQL
versions.
- * On startup log brep module name to Apache2 log.
+ * On startup log brep module version to Apache2 log.
Version 0.2.2
diff --git a/brep/database.cxx b/brep/database.cxx
index 1f70881..4b56c37 100644
--- a/brep/database.cxx
+++ b/brep/database.cxx
@@ -7,6 +7,7 @@
#include <map>
#include <odb/pgsql/database.hxx>
+#include <odb/pgsql/connection-factory.hxx>
namespace brep
{
@@ -26,11 +27,11 @@ namespace brep
}
}
- shared_ptr<odb::database>
+ using namespace odb;
+
+ shared_ptr<database>
shared_database (const options::db& o)
{
- using odb::pgsql::database;
-
static std::map<options::db, weak_ptr<database>> databases;
auto i (databases.find (o));
@@ -40,14 +41,18 @@ namespace brep
return d;
}
+ unique_ptr<pgsql::connection_factory>
+ f (new pgsql::connection_pool_factory (o.db_max_connections ()));
+
shared_ptr<database> d (
- make_shared<database> (
+ make_shared<pgsql::database> (
o.db_user (),
o.db_password (),
o.db_name (),
o.db_host (),
o.db_port (),
- "options='-c default_transaction_isolation=serializable'"));
+ "options='-c default_transaction_isolation=serializable'",
+ move (f)));
databases[o] = d;
return d;
diff --git a/brep/options.cli b/brep/options.cli
index bcb335e..d63a561 100644
--- a/brep/options.cli
+++ b/brep/options.cli
@@ -72,6 +72,13 @@ namespace brep
"Database port number. If not specified, the default port is used."
}
+ size_t db-max-connections = 5
+ {
+ "<num>",
+ "The maximum number of concurrent database connections per web server
+ process. If 0, then no limitation is applied. The default is 5."
+ }
+
size_t db-retry = 10
{
"<num>",
diff --git a/etc/brep-module.conf b/etc/brep-module.conf
index 05fd278..82a21e1 100644
--- a/etc/brep-module.conf
+++ b/etc/brep-module.conf
@@ -49,6 +49,10 @@ menu About=?about
# db-host
# db-port
+# The maximum number of concurrent database connections per web server
+# process. If 0, then no limitation is applied.
+#
+# db-max-connections 5
# The maximum number of times to retry database transactions in the
# face of recoverable failures (deadlock, loss of connection, etc).
diff --git a/web/apache/service b/web/apache/service
index c663323..b50bc13 100644
--- a/web/apache/service
+++ b/web/apache/service
@@ -35,10 +35,10 @@ namespace web
// It then initializes each of these "context exemplars" with the (merged)
// set of configuration options. Finally, when handling a request, it
// copies the corresponding "context exemplar" to create the "handling
- // instance". Note that the "context exemplars" are create before the
- // provided exemplar is initialized. As a result, it is possible to detect
- // if the module's copy constructor is used to create a "context exemplar"
- // or a "handling instance".
+ // instance". Note that the "context exemplars" are created as a copy of
+ // the provided exemplar, which is never initialized. As a result, it is
+ // possible to detect if the module's copy constructor is used to create a
+ // "context exemplar" or a "handling instance".
//
class service: ::module
{
@@ -86,7 +86,7 @@ namespace web
// contexts options with the ones from the enclosing servers.
//
// 5. Apache calls worker_initializer() which creates module exemplar
- // for each directory configuration context having
+ // for each directory configuration context that have
// 'SetHandler <mod_name>' directive in effect for it.
//
// References:
@@ -172,13 +172,13 @@ namespace web
enum class request_handling
{
// Configuration scope has 'SetHandler <mod_name>' directive
- // specified. The module allowed to handle a request in the scope.
+ // specified. The module is allowed to handle a request in the scope.
//
allowed,
// Configuration scope has 'SetHandler <other_mod_name>|None'
- // directive specified. The module disallowed to handle a request in
- // the scope.
+ // directive specified. The module is disallowed to handle a request
+ // in the scope.
//
disallowed,
@@ -307,13 +307,13 @@ namespace web
module& exemplar_;
option_descriptions option_descriptions_;
- // The context objects pointed by the key can change during the
+ // The context objects pointed to by the key can change during the
// configuration phase.
//
using options = std::map<context*, name_values>;
options options_;
- // The context objects pointed by the key can not change during the
+ // The context objects pointed to by the key can not change during the
// request handling phase.
//
using exemplars = std::map<const context*, std::unique_ptr<module>>;
diff --git a/web/apache/service.cxx b/web/apache/service.cxx
index 6679194..7104731 100644
--- a/web/apache/service.cxx
+++ b/web/apache/service.cxx
@@ -69,9 +69,9 @@ namespace web
};
}
- // Track if the module allowed to handle a request in the specific
+ // Track if the module is allowed to handle a request in the specific
// configuration scope. The module exemplar will be created (and
- // initialized) only for configuration contexts having
+ // initialized) only for configuration contexts that have
// 'SetHandler <mod_name>' in effect for the corresponding scope.
//
*d++ =
@@ -217,8 +217,8 @@ namespace web
auto i (options_.find (enclosing));
// The enclosing context may have no options. It can be the context of a
- // server having no configuration directives in it's immediate scope,
- // but having ones in it's enclosed scope (directory or virtual server).
+ // server that has no configuration directives in it's immediate scope,
+ // but has ones in it's enclosed scope (directory or virtual server).
//
if (i != options_.end ())
{
diff --git a/web/apache/service.txx b/web/apache/service.txx
index 2e8a3e5..e517abe 100644
--- a/web/apache/service.txx
+++ b/web/apache/service.txx
@@ -25,7 +25,7 @@ namespace web
const M* exemplar (dynamic_cast<const M*> (&exemplar_));
assert (exemplar != nullptr);
- // For each directory configuration context, for which the module
+ // For each directory configuration context, for which the module is
// allowed to handle a request, create the module exemplar as a deep
// copy of the exemplar_ member, and initialize it with the
// context-specific option list.