Skip to content

Commit

Permalink
Merge pull request #267 from michelsciortino/ms-increasing-pistache-m…
Browse files Browse the repository at this point in the history
…ax-payload

Implementing maxPayload Pistache option personalization
  • Loading branch information
frisso committed Feb 9, 2020
2 parents a42dd1f + 473f505 commit 5afda68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/polycubed/src/polycubed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,15 @@ int main(int argc, char *argv[]) {

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

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

// start rest server
restserver = new RestServer(addr, *core);
restserver->init(thr, config.getCertPath(), config.getKeyPath(),
restserver->init(thr, max_payload_size, config.getCertPath(), config.getKeyPath(),
config.getCACertPath(), config.getCertWhitelistPath(),
config.getCertBlacklistPath());
core->set_rest_server(restserver);
Expand Down
12 changes: 8 additions & 4 deletions src/polycubed/src/rest_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,19 @@ int RestServer::client_verify_callback(int preverify_ok, void *ctx) {
return preverify_ok;
}

void RestServer::init(size_t thr, const std::string &server_cert,
void RestServer::init(size_t thr,
size_t max_payload_size,
const std::string &server_cert,
const std::string &server_key,
const std::string &root_ca_cert,
const std::string &whitelist_cert_path_,
const std::string &blacklist_cert_path_) {
logger->debug("rest server will use {0} thread(s)", thr);
auto opts = Pistache::Http::Endpoint::options().threads(thr).flags(
Pistache::Tcp::Options::InstallSignalHandler |
Pistache::Tcp::Options::ReuseAddr);
auto opts = Pistache::Http::Endpoint::options()
.threads(thr)
.maxPayload(max_payload_size)
.flags(Pistache::Tcp::Options::InstallSignalHandler |
Pistache::Tcp::Options::ReuseAddr);
httpEndpoint_->init(opts);

if (!server_cert.empty()) {
Expand Down
4 changes: 3 additions & 1 deletion src/polycubed/src/rest_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class RestServer {

static const std::string base;

void init(size_t thr = 1, const std::string &server_cert = "",
void init(size_t thr = 1,
size_t max_payload_size = 64*1024,
const std::string &server_cert = "",
const std::string &server_key = "",
const std::string &root_ca_cert = "",
const std::string &white_cert_list_path = "",
Expand Down

0 comments on commit 5afda68

Please sign in to comment.