From bad54b28bcc59fe5d19ecaf486f52e6359009e68 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 21 May 2024 13:48:43 +0300 Subject: Add support for build_unloaded() notification for tenant-associated services --- mod/mod-build-force.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'mod/mod-build-force.cxx') 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>> 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 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)); -- cgit v1.1