diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-05-21 13:48:43 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-05-21 13:50:10 +0300 |
commit | bad54b28bcc59fe5d19ecaf486f52e6359009e68 (patch) | |
tree | 4dcc9c10413d46bf9f506863b6f154ee5998e469 /mod/mod-build-force.cxx | |
parent | c4798955364d3a5e4074e56a0038148837c75d82 (diff) |
Add support for build_unloaded() notification for tenant-associated services
Diffstat (limited to 'mod/mod-build-force.cxx')
-rw-r--r-- | mod/mod-build-force.cxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mod/mod-build-force.cxx b/mod/mod-build-force.cxx index bdae356..168a835 100644 --- a/mod/mod-build-force.cxx +++ b/mod/mod-build-force.cxx @@ -192,7 +192,14 @@ handle (request& rq, response& rs) optional<pair<tenant_service, shared_ptr<build>>> tss; tenant_service_build_queued::build_queued_hints qhs; + // Acquire the database connection for the subsequent transactions. + // + // Note that we will release it prior to any potentially time-consuming + // operations (such as HTTP requests) and re-acquire it again afterwards, + // if required. + // connection_ptr conn (build_db_->connection ()); + { transaction t (conn->begin ()); @@ -297,14 +304,28 @@ handle (request& rq, response& rs) vector<build> qbs; qbs.push_back (move (b)); + // Release the database connection since the build_queued() notification + // can potentially be time-consuming (e.g., it may perform an HTTP + // request). + // + conn.reset (); + if (auto f = tsq->build_queued (ss, qbs, build_state::building, qhs, log_writer_)) + { + conn = build_db_->connection (); update_tenant_service_state (conn, qbs.back ().tenant, f); + } } + // Release the database connection prior to writing into the unbuffered + // response stream. + // + conn.reset (); + // We have all the data, so don't buffer the response content. // ostream& os (rs.content (200, "text/plain;charset=utf-8", false)); |