Skip to content

Commit 9d4e740

Browse files
committed
fcgi/Stock: pass CgiChildParams to Get()
Reducing the number of parameters, making the API simpler.
1 parent bd23540 commit 9d4e740

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/fcgi/Request.cxx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "http/PendingRequest.hxx"
1010
#include "http/ResponseHandler.hxx"
1111
#include "cgi/Address.hxx"
12+
#include "cgi/ChildParams.hxx"
1213
#include "stock/AbstractStock.hxx"
1314
#include "stock/GetHandler.hxx"
1415
#include "stock/Item.hxx"
@@ -89,13 +90,18 @@ class FcgiRequest final
8990
}
9091

9192
void BeginConnect() noexcept {
93+
auto *params = NewFromPool<CgiChildParams>(pool,
94+
address.GetAction(),
95+
address.args.ToArray(pool),
96+
address.options,
97+
address.parallelism,
98+
address.concurrency,
99+
false);
100+
92101
const TempPoolLease tpool;
93102
const auto key = address.GetChildId(*tpool);
94103

95-
fcgi_stock.Get(key, address.options,
96-
address.GetAction(), address.args.ToArray(pool),
97-
address.parallelism, address.concurrency,
98-
*this, cancel_ptr);
104+
fcgi_stock.Get(key, *params, *this, cancel_ptr);
99105
}
100106

101107
private:

src/fcgi/Stock.cxx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,21 +192,16 @@ FcgiStock::FadeTag(std::string_view tag) noexcept
192192
}
193193

194194
void
195-
FcgiStock::Get(StockKey key, const ChildOptions &options,
196-
const char *executable_path,
197-
std::span<const char *const> args,
198-
unsigned parallelism, unsigned concurrency,
195+
FcgiStock::Get(StockKey key, const CgiChildParams &params,
199196
StockGetHandler &handler,
200197
CancellablePointer &cancel_ptr) noexcept
201198
{
199+
unsigned concurrency = params.concurrency;
202200
if (concurrency <= 1)
203201
/* no concurrency by default */
204202
concurrency = 1;
205203

206-
auto r = ToDeletePointer(new CgiChildParams(executable_path,
207-
args, options,
208-
parallelism, concurrency, false));
209-
mchild_stock.Get(key, std::move(r),
204+
mchild_stock.Get(key, ToNopPointer(&params),
210205
concurrency,
211206
handler, cancel_ptr);
212207
}

src/fcgi/Stock.hxx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct ChildErrorLogOptions;
1616
class StockItem;
1717
class StockGetHandler;
1818
class FcgiStock;
19-
struct ChildOptions;
19+
struct CgiChildParams;
2020
class EventLoop;
2121
class SpawnService;
2222
class ListenStreamStock;
@@ -49,12 +49,11 @@ public:
4949
}
5050

5151
/**
52-
* @param args command-line arguments
52+
* @param params a description of the FastCGI process; the
53+
* pointed-to object must remain valid until the request
54+
* completes
5355
*/
54-
void Get(StockKey key, const ChildOptions &options,
55-
const char *executable_path,
56-
std::span<const char *const> args,
57-
unsigned parallelism, unsigned concurrency,
56+
void Get(StockKey key, const CgiChildParams &params,
5857
StockGetHandler &handler,
5958
CancellablePointer &cancel_ptr) noexcept;
6059

0 commit comments

Comments
 (0)