This is an automated email from the ASF dual-hosted git repository. masaori pushed a commit to branch quic-latest in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 36b9f22cb5d0d97f6f73a9a86f857bb80c8a8b76 Author: Masaori Koshiba <[email protected]> AuthorDate: Mon Apr 23 16:19:27 2018 +0900 Add QUICClientConfig --- cmd/traffic_quic/quic_client.cc | 9 +++++++-- cmd/traffic_quic/quic_client.h | 17 +++++++++-------- cmd/traffic_quic/traffic_quic.cc | 17 +++++++---------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/cmd/traffic_quic/quic_client.cc b/cmd/traffic_quic/quic_client.cc index 2729f6d..7f10fd4 100644 --- a/cmd/traffic_quic/quic_client.cc +++ b/cmd/traffic_quic/quic_client.cc @@ -23,6 +23,11 @@ #include "quic_client.h" +QUICClient::~QUICClient(const QUICClientConfig *config) : Continuation(new_ProxyMutex()), _config(config) +{ + SET_HANDLER(&QUICClient::start); +} + QUICClient::~QUICClient() { freeaddrinfo(this->_remote_addr_info); @@ -41,7 +46,7 @@ QUICClient::start(int, void *) hints.ai_flags = 0; hints.ai_protocol = 0; - int res = getaddrinfo(this->_remote_addr, this->_remote_port, &hints, &this->_remote_addr_info); + int res = getaddrinfo(this->_config->addr, this->_config->port, &hints, &this->_remote_addr_info); if (res < 0) { Debug("quic_client", "Error: %s (%d)", strerror(errno), errno); return EVENT_DONE; @@ -76,7 +81,7 @@ QUICClient::state_http_server_open(int event, void *data) QUICNetVConnection *conn = static_cast<QUICNetVConnection *>(data); QUICClientApp *app = new QUICClientApp(conn); - app->start(this->_path); + app->start(this->_config->path); break; } diff --git a/cmd/traffic_quic/quic_client.h b/cmd/traffic_quic/quic_client.h index 15071c3..8a13a49 100644 --- a/cmd/traffic_quic/quic_client.h +++ b/cmd/traffic_quic/quic_client.h @@ -30,24 +30,25 @@ #include "QUICApplication.h" +struct QUICClientConfig { + char addr[1024] = "127.0.0.1"; + char port[16] = "4433"; + char path[1018] = "/"; + char debug_tags[1024] = "quic"; +}; + class QUICClient : public Continuation { public: - QUICClient(const char *addr, const char *port, const char *path) - : Continuation(new_ProxyMutex()), _remote_addr(addr), _remote_port(port), _path(path) - { - SET_HANDLER(&QUICClient::start); - }; + QUICClient(const QUICClientConfig *config); ~QUICClient(); int start(int, void *); int state_http_server_open(int event, void *data); private: - const char *_remote_addr = nullptr; - const char *_remote_port = nullptr; + const QUICClientConfig *_config = nullptr; struct addrinfo *_remote_addr_info = nullptr; - const char *_path = nullptr; }; class QUICClientApp : public QUICApplication diff --git a/cmd/traffic_quic/traffic_quic.cc b/cmd/traffic_quic/traffic_quic.cc index 2098d49..7e85b38 100644 --- a/cmd/traffic_quic/traffic_quic.cc +++ b/cmd/traffic_quic/traffic_quic.cc @@ -49,16 +49,13 @@ main(int argc, const char **argv) AppVersionInfo appVersionInfo; appVersionInfo.setup(PACKAGE_NAME, "traffic_quic", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, ""); - char addr[1024] = "127.0.0.1"; - char port[16] = "4433"; - char path[1018] = "/"; - char debug_tags[1024] = "quic"; + QUICClientConfig config; const ArgumentDescription argument_descriptions[] = { - {"addr", 'a', "Address", "S1023", addr, nullptr, nullptr}, - {"port", 'p', "Port", "S15", port, nullptr, nullptr}, - {"path", 'P', "Path", "S1017", path, nullptr, nullptr}, - {"debug", 'T', "Vertical-bar-separated Debug Tags", "S1023", debug_tags, nullptr, nullptr}, + {"addr", 'a', "Address", "S1023", config.addr, nullptr, nullptr}, + {"port", 'p', "Port", "S15", config.port, nullptr, nullptr}, + {"path", 'P', "Path", "S1017", config.path, nullptr, nullptr}, + {"debug", 'T', "Vertical-bar-separated Debug Tags", "S1023", config.debug_tags, nullptr, nullptr}, HELP_ARGUMENT_DESCRIPTION(), VERSION_ARGUMENT_DESCRIPTION(), RUNROOT_ARGUMENT_DESCRIPTION(), @@ -67,7 +64,7 @@ main(int argc, const char **argv) // Process command line arguments and dump into variables process_args(&appVersionInfo, argument_descriptions, countof(argument_descriptions), argv); - init_diags(debug_tags, nullptr); + init_diags(config.debug_tags, nullptr); RecProcessInit(RECM_STAND_ALONE); LibRecordsConfigInit(); @@ -89,7 +86,7 @@ main(int argc, const char **argv) udpNet.start(1, stacksize); quic_NetProcessor.start(-1, stacksize); - QUICClient client(addr, port, path); + QUICClient client(&config); eventProcessor.schedule_in(&client, 1, ET_NET); this_thread()->execute(); -- To stop receiving notification emails like this one, please contact [email protected].
