[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Tatiana |
Date: |
Sun, 22 Jul 2018 10:48:33 -0400 (EDT) |
branch: web-interface
commit 7453c2343acb28d651026d27b916e3c9d837ad6e
Author: TSholokhova <address@hidden>
Date: Sun Jul 22 16:47:46 2018 +0200
Fix with-critical-section wrapping.
* /src/cuirass/http.scm: Use one critical-section per function.
---
src/cuirass/http.scm | 128 +++++++++++++++++++++++++--------------------------
1 file changed, 64 insertions(+), 64 deletions(-)
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index dcf1641..38a5f49 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -97,19 +97,20 @@
(#:releasename . #nil)
(#:buildinputs_builds . #nil)))
-(define (handle-build-request db-channel build-id)
- "Retrieve build identified by BUILD-ID over DB-CHANNEL and convert it
+(define (handle-build-request db build-id)
+ "Retrieve build identified by BUILD-ID over DB and convert it
to hydra format. Return #f is not build was found."
- (let ((build (with-critical-section db-channel (db)
- (db-get-build db build-id))))
- (and=> build build->hydra-build)))
+ (let ((build (db-get-build db build-id)))
+ (and=> build build->hydra-build)))
-(define (handle-builds-request db-channel filters)
- "Retrieve all builds matched by FILTERS in DB-CHANNEL and convert them
+(define (handle-builds-request db filters)
+ "Retrieve all builds matched by FILTERS in DB and convert them
to Hydra format."
- (let ((builds (with-critical-section db-channel (db)
- (with-time-logging "builds request"
- (db-get-builds db filters)))))
+ (let
+ ((builds
+ (with-time-logging
+ "builds request"
+ (db-get-builds db filters))))
(map build->hydra-build builds)))
(define (request-parameters request)
@@ -217,12 +218,15 @@
(with-critical-section db-channel (db)
(db-get-specifications db)))))
(("build" build-id)
- (let ((hydra-build (handle-build-request
- db-channel
- (string->number build-id))))
+ (let
+ ((hydra-build
+ (with-critical-section db-channel (db)
+ (handle-build-request
+ db
+ (string->number build-id)))))
(if hydra-build
- (respond-json (object->json-string hydra-build))
- (respond-build-not-found build-id))))
+ (respond-json (object->json-string hydra-build))
+ (respond-build-not-found build-id))))
(("build" build-id "log" "raw")
(let ((build (with-critical-section db-channel (db)
(db-get-build db (string->number build-id)))))
@@ -263,11 +267,12 @@
(if valid-params?
;; Limit results to builds that are "done".
(respond-json (object->json-string
- (handle-builds-request
- db-channel
- `((status done)
- ,@params
- (order finish-time)))))
+ (with-critical-section db-channel (db)
+ (handle-builds-request
+ db
+ `((status done)
+ ,@params
+ (order finish-time))))))
(respond-json-with-error 500 "Parameter not defined!"))))
(("api" "queue")
(let* ((params (request-parameters request))
@@ -293,52 +298,47 @@
(db-get-specifications db))))))
(("jobset" name)
- (let*
- ((evaluation-id-max
- (with-critical-section db-channel (db)
- (db-get-evaluations-id-max db name)))
- (evaluation-id-min
- (with-critical-section db-channel (db)
- (db-get-evaluations-id-min db name)))
- (params (request-parameters request))
- (border-high (assqx-ref params 'border-high))
- (border-low (assqx-ref params 'border-low)))
- (respond-html
- (html-page
- name
- (evaluation-info-table
- name
- (with-critical-section db-channel (db)
- (db-get-evaluations-build-summary
- db
- name
- (%pagesize)
- border-low
- border-high))
- evaluation-id-min
- evaluation-id-max)))))
+ (respond-html
+ (with-critical-section db-channel (db)
+ (let*
+ ((evaluation-id-max (db-get-evaluations-id-max db name))
+ (evaluation-id-min (db-get-evaluations-id-min db name))
+ (params (request-parameters request))
+ (border-high (assqx-ref params 'border-high))
+ (border-low (assqx-ref params 'border-low)))
+ (html-page
+ name
+ (evaluation-info-table
+ name
+ (db-get-evaluations-build-summary
+ db
+ name
+ (%pagesize)
+ border-low
+ border-high)
+ evaluation-id-min
+ evaluation-id-max))))))
(("eval" id)
- (let*
- ((builds-id-max (with-critical-section db-channel (db)
- (db-get-builds-id-max db id)))
- (builds-id-min (with-critical-section db-channel (db)
- (db-get-builds-id-min db id)))
- (params (request-parameters request))
- (border-high (normalize-parameter (assq-ref params 'border-high)))
- (border-low (normalize-parameter (assq-ref params 'border-low))))
- (respond-html
- (html-page
- "Evaluations"
- (build-eval-table
- (handle-builds-request db-channel
- `((evaluation ,id)
- (nr ,(%pagesize))
- (order finish-time)
- (border-high ,border-high)
- (border-low ,border-low)))
- builds-id-min
- builds-id-max)))))
+ (respond-html
+ (with-critical-section db-channel (db)
+ (let*
+ ((builds-id-max (db-get-builds-id-max db id))
+ (builds-id-min (db-get-builds-id-min db id))
+ (params (request-parameters request))
+ (border-high (assqx-ref params 'border-high))
+ (border-low (assqx-ref params 'border-low)))
+ (html-page
+ "Evaluations"
+ (build-eval-table
+ (handle-builds-request db
+ `((evaluation ,id)
+ (nr ,(%pagesize))
+ (order finish-time)
+ (border-high ,border-high)
+ (border-low ,border-low)))
+ builds-id-min
+ builds-id-max))))))
(("static" path ...)
(respond-static-file path))