From b4b921c9130ddf4972b8ba7db7a3a2cf0908960d Mon Sep 17 00:00:00 2001 From: nnposter Date: Sun, 26 Oct 2025 02:14:47 +0000 Subject: [PATCH] Streamline the code by using math.min() --- nselib/http.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/nselib/http.lua b/nselib/http.lua index 0384e21a3..c7302cfbc 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -2034,15 +2034,10 @@ function pipeline_go(host, port, all_requests) partial = "" connsent = 0 end - if connlimit > connsent + #all_requests - #responses then - connlimit = connsent + #all_requests - #responses - end - + -- decrease the connection limit to match what we still need to send + connlimit = math.min(connlimit, connsent + #all_requests - #responses) -- determine the current batch size - local batchsize = connlimit - connsent - if batchsize > batchlimit then - batchsize = batchlimit - end + local batchsize = math.min(connlimit - connsent, batchlimit) stdnse.debug3("HTTP pipeline: batch=%d, conn=%d/%d, resp=%d/%d", batchsize, connsent, connlimit, #responses, #all_requests) -- build and send a batch of requests