Browse Source

H2O: Use 2 database connections per thread again (#9176)

Anton Kirilov 1 year ago
parent
commit
57f2f11748
2 changed files with 5 additions and 5 deletions
  1. 1 1
      frameworks/C/h2o/h2o.dockerfile
  2. 4 4
      frameworks/C/h2o/src/handlers/world.c

+ 1 - 1
frameworks/C/h2o/h2o.dockerfile

@@ -109,4 +109,4 @@ CMD ["taskset", \
      "dbname=hello_world host=tfb-database password=benchmarkdbpass sslmode=disable user=benchmarkdbuser", \
      "-f", \
      "/opt/h2o_app/share/h2o_app/template", \
-     "-m1"]
+     "-m2"]

+ 4 - 4
frameworks/C/h2o/src/handlers/world.c

@@ -237,9 +237,9 @@ static int do_multiple_queries(bool do_update, bool use_cache, h2o_req_t *req)
 
 	const size_t num_query = get_query_number(req);
 
-	// MAX_QUERIES is a relatively small number, so assume no overflow in the following
-	// arithmetic operations.
-	assert(num_query && num_query <= MAX_QUERIES);
+	// MAX_QUERIES is a relatively small number, say less than or equal to UINT16_MAX, so assume no
+	// overflow in the following arithmetic operations.
+	assert(num_query && num_query <= MAX_QUERIES && num_query <= UINT16_MAX);
 
 	size_t base_size = offsetof(multiple_query_ctx_t, res) + num_query * sizeof(query_result_t);
 
@@ -373,7 +373,7 @@ static void do_updates(multiple_query_ctx_t *query_ctx)
 	for (size_t i = 0; i < query_ctx->num_result; i++) {
 		query_ctx->res[i].id = htonl(query_ctx->res[i].id);
 		query_ctx->res[i].random_number =
-				htonl(1 + get_random_number(MAX_ID, &query_ctx->ctx->random_seed));
+			htonl(1 + get_random_number(MAX_ID, &query_ctx->ctx->random_seed));
 		paramFormats[2 * i] = 1;
 		paramFormats[2 * i + 1] = 1;
 		paramLengths[2 * i] = sizeof(query_ctx->res[i].id);