Skip to content

Commit 5afda68

Browse files
authored
Merge pull request #267 from michelsciortino/ms-increasing-pistache-max-payload
Implementing maxPayload Pistache option personalization
2 parents a42dd1f + 473f505 commit 5afda68

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/polycubed/src/polycubed.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,15 @@ int main(int argc, char *argv[]) {
274274

275275
// setup rest server
276276
int thr = 4;
277+
size_t max_payload_size = 1024*1024; // 1MB
277278
Address addr(config.getServerIP(), Pistache::Port(config.getServerPort()));
278279

279280
// logger->info("Cores = {0}", hardware_concurrency());
280281
// logger->info("Using {0} threads", thr);
281282

282283
// start rest server
283284
restserver = new RestServer(addr, *core);
284-
restserver->init(thr, config.getCertPath(), config.getKeyPath(),
285+
restserver->init(thr, max_payload_size, config.getCertPath(), config.getKeyPath(),
285286
config.getCACertPath(), config.getCertWhitelistPath(),
286287
config.getCertBlacklistPath());
287288
core->set_rest_server(restserver);

src/polycubed/src/rest_server.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,19 @@ int RestServer::client_verify_callback(int preverify_ok, void *ctx) {
116116
return preverify_ok;
117117
}
118118

119-
void RestServer::init(size_t thr, const std::string &server_cert,
119+
void RestServer::init(size_t thr,
120+
size_t max_payload_size,
121+
const std::string &server_cert,
120122
const std::string &server_key,
121123
const std::string &root_ca_cert,
122124
const std::string &whitelist_cert_path_,
123125
const std::string &blacklist_cert_path_) {
124126
logger->debug("rest server will use {0} thread(s)", thr);
125-
auto opts = Pistache::Http::Endpoint::options().threads(thr).flags(
126-
Pistache::Tcp::Options::InstallSignalHandler |
127-
Pistache::Tcp::Options::ReuseAddr);
127+
auto opts = Pistache::Http::Endpoint::options()
128+
.threads(thr)
129+
.maxPayload(max_payload_size)
130+
.flags(Pistache::Tcp::Options::InstallSignalHandler |
131+
Pistache::Tcp::Options::ReuseAddr);
128132
httpEndpoint_->init(opts);
129133

130134
if (!server_cert.empty()) {

src/polycubed/src/rest_server.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class RestServer {
5252

5353
static const std::string base;
5454

55-
void init(size_t thr = 1, const std::string &server_cert = "",
55+
void init(size_t thr = 1,
56+
size_t max_payload_size = 64*1024,
57+
const std::string &server_cert = "",
5658
const std::string &server_key = "",
5759
const std::string &root_ca_cert = "",
5860
const std::string &white_cert_list_path = "",

0 commit comments

Comments
 (0)