Skip to content

Commit 7cc83e5

Browse files
committed
was/Stock: pass CgiChildParams to Get()
1 parent 9d4e740 commit 7cc83e5

6 files changed

Lines changed: 37 additions & 52 deletions

File tree

src/was/Glue.cxx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "Stock.hxx"
77
#include "SRequest.hxx"
88
#include "cgi/Address.hxx"
9+
#include "cgi/ChildParams.hxx"
910
#include "pool/pool.hxx"
1011
#include "pool/tpool.hxx"
1112
#include "util/StringCompare.hxx"
@@ -16,7 +17,6 @@
1617
class WasRequest final : WasStockRequest {
1718
WasStock &was_stock;
1819
const CgiAddress &address;
19-
const std::span<const char *const> args;
2020

2121
public:
2222
WasRequest(struct pool &_pool, WasStock &_was_stock,
@@ -37,8 +37,7 @@ class WasRequest final : WasStockRequest {
3737
_address.params.ToArray(_pool),
3838
_metrics_handler, _handler),
3939
was_stock(_was_stock),
40-
address(_address),
41-
args(address.args.ToArray(pool)) {}
40+
address(_address) {}
4241

4342
using WasStockRequest::WasStockRequest;
4443

@@ -49,13 +48,17 @@ class WasRequest final : WasStockRequest {
4948

5049
protected:
5150
void GetStockItem() noexcept override {
51+
auto r = NewFromPool<CgiChildParams>(pool, address.GetAction(),
52+
address.args.ToArray(pool),
53+
address.options,
54+
address.parallelism,
55+
address.concurrency,
56+
address.disposable);
57+
5258
const TempPoolLease tpool;
5359
const auto key = address.GetChildId(*tpool);
5460

55-
was_stock.Get(pool, key,
56-
address.options,
57-
address.GetAction(), args,
58-
address.parallelism, address.disposable,
61+
was_stock.Get(key, *r,
5962
*this, cancel_ptr);
6063
}
6164
};

src/was/MGlue.cxx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "pool/tpool.hxx"
1212
#include "stopwatch.hxx"
1313
#include "cgi/Address.hxx"
14+
#include "cgi/ChildParams.hxx"
1415
#include "net/FormatAddress.hxx"
1516
#include "util/StringCompare.hxx"
1617
#include "AllocatorPtr.hxx"
@@ -52,13 +53,17 @@ class MultiWasRequest final : WasStockRequest
5253

5354
protected:
5455
void GetStockItem() noexcept override {
56+
auto r = NewFromPool<CgiChildParams>(pool, address.GetAction(),
57+
address.args.ToArray(pool),
58+
address.options,
59+
address.parallelism,
60+
address.concurrency,
61+
address.disposable);
62+
5563
const TempPoolLease tpool;
5664
const auto key = address.GetChildId(*tpool);
5765

58-
stock.Get(pool, key,
59-
address.options,
60-
address.GetAction(), args,
61-
address.parallelism, address.concurrency,
66+
stock.Get(key, *r,
6267
*this, cancel_ptr);
6368
}
6469
};

src/was/MStock.cxx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,11 @@ MultiWasStock::FadeTag(std::string_view tag) noexcept
206206
}
207207

208208
void
209-
MultiWasStock::Get(AllocatorPtr alloc,
210-
StockKey key,
211-
const ChildOptions &options,
212-
const char *executable_path,
213-
std::span<const char *const> args,
214-
unsigned parallelism, unsigned concurrency,
209+
MultiWasStock::Get(StockKey key, const CgiChildParams &params,
215210
StockGetHandler &handler,
216211
CancellablePointer &cancel_ptr) noexcept
217212
{
218-
auto r = NewDisposablePointer<CgiChildParams>(alloc, executable_path,
219-
args, options,
220-
parallelism, concurrency,
221-
false);
222-
223-
mchild_stock.Get(key, std::move(r), concurrency, handler, cancel_ptr);
213+
mchild_stock.Get(key, ToNopPointer(&params),
214+
params.concurrency,
215+
handler, cancel_ptr);
224216
}

src/was/MStock.hxx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <span>
1313

1414
class AllocatorPtr;
15-
struct ChildOptions;
15+
struct CgiChildParams;
1616
class StockItem;
1717
struct WasSocket;
1818
class SocketDescriptor;
@@ -72,13 +72,12 @@ public:
7272
/**
7373
* The resulting #StockItem will be a #WasStockConnection
7474
* instance.
75+
*
76+
* @param params a description of the WAS process; the
77+
* pointed-to object must remain valid until the request
78+
* completes
7579
*/
76-
void Get(AllocatorPtr alloc,
77-
StockKey key,
78-
const ChildOptions &options,
79-
const char *executable_path,
80-
std::span<const char *const> args,
81-
unsigned parallelism, unsigned concurrency,
80+
void Get(StockKey key, const CgiChildParams &params,
8281
StockGetHandler &handler,
8382
CancellablePointer &cancel_ptr) noexcept;
8483

src/was/Stock.cxx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,10 @@ WasChild::~WasChild() noexcept = default;
136136
*/
137137

138138
void
139-
WasStock::Get(AllocatorPtr alloc,
140-
StockKey key,
141-
const ChildOptions &options,
142-
const char *executable_path,
143-
std::span<const char *const> args,
144-
unsigned parallelism, bool disposable,
139+
WasStock::Get(StockKey key, const CgiChildParams &params,
145140
StockGetHandler &handler,
146141
CancellablePointer &cancel_ptr) noexcept
147142
{
148-
149-
auto r = NewDisposablePointer<CgiChildParams>(alloc, executable_path,
150-
args, options,
151-
parallelism,
152-
0,
153-
disposable);
154-
155-
stock.Get(key, std::move(r), handler, cancel_ptr);
143+
stock.Get(key, ToNopPointer(&params),
144+
handler, cancel_ptr);
156145
}

src/was/Stock.hxx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace Net::Log { class Sink; }
1818
class AllocatorPtr;
19-
struct ChildOptions;
19+
struct CgiChildParams;
2020
struct WasSocket;
2121
class SpawnService;
2222
class ListenStreamStock;
@@ -88,14 +88,11 @@ public:
8888
* The resulting #StockItem will be a #WasStockConnection
8989
* instance.
9090
*
91-
* @param args command-line arguments
91+
* @param params a description of the WAS process; the
92+
* pointed-to object must remain valid until the request
93+
* completes
9294
*/
93-
void Get(AllocatorPtr alloc,
94-
StockKey key,
95-
const ChildOptions &options,
96-
const char *executable_path,
97-
std::span<const char *const> args,
98-
unsigned parallelism, bool disposable,
95+
void Get(StockKey key, const CgiChildParams &params,
9996
StockGetHandler &handler,
10097
CancellablePointer &cancel_ptr) noexcept;
10198

0 commit comments

Comments
 (0)