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
The following commit(s) were added to refs/heads/quic-latest by this push:
new 28970d7 Add a option to enable connection close excercise
28970d7 is described below
commit 28970d79c990dc7c0274ff35269ce1fec412cc45
Author: Masaori Koshiba <[email protected]>
AuthorDate: Tue Jun 26 10:59:41 2018 +0900
Add a option to enable connection close excercise
---
src/traffic_quic/quic_client.cc | 16 +++++++---------
src/traffic_quic/quic_client.h | 7 +++++--
src/traffic_quic/traffic_quic.cc | 1 +
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/traffic_quic/quic_client.cc b/src/traffic_quic/quic_client.cc
index 119b9c3..b5237ac 100644
--- a/src/traffic_quic/quic_client.cc
+++ b/src/traffic_quic/quic_client.cc
@@ -83,13 +83,7 @@ QUICClient::state_http_server_open(int event, void *data)
Debug("quic_client", "start proxy server ssn/txn");
QUICNetVConnection *conn = static_cast<QUICNetVConnection *>(data);
-
- const char *filename = nullptr;
- if (this->_config->output[0] != 0x0) {
- filename = this->_config->output;
- }
-
- QUICClientApp *app = new QUICClientApp(conn, filename);
+ QUICClientApp *app = new QUICClientApp(conn, this->_config);
app->start(this->_config->path);
break;
@@ -115,7 +109,7 @@ QUICClient::state_http_server_open(int event, void *data)
#define QUICClientAppDebug(fmt, ...) Debug("quic_client_app", "[%s] " fmt,
this->_qc->cids().data(), ##__VA_ARGS__)
#define QUICClientAppVDebug(fmt, ...) Debug("v_quic_client_app", "[%s] " fmt,
this->_qc->cids().data(), ##__VA_ARGS__)
-QUICClientApp::QUICClientApp(QUICNetVConnection *qvc, const char *filename) :
QUICApplication(qvc), _filename(filename)
+QUICClientApp::QUICClientApp(QUICNetVConnection *qvc, const QUICClientConfig
*config) : QUICApplication(qvc), _config(config)
{
this->_qc->stream_manager()->set_default_application(this);
@@ -125,6 +119,10 @@ QUICClientApp::QUICClientApp(QUICNetVConnection *qvc,
const char *filename) : QU
void
QUICClientApp::start(const char *path)
{
+ if (this->_config->output[0] != 0x0) {
+ this->_filename = this->_config->output;
+ }
+
if (this->_filename) {
// Destroy contents if file already exists
std::ofstream f_stream(this->_filename, std::ios::binary |
std::ios::trunc);
@@ -191,7 +189,7 @@ QUICClientApp::main_event_handler(int event, Event *data)
std::cout.rdbuf(default_stream);
}
- if (stream_io->is_read_done()) {
+ if (stream_io->is_read_done() && this->_config->close) {
// Connection Close Exercise
this->_qc->close(QUICConnectionErrorUPtr(new
QUICConnectionError(QUICTransErrorCode::NO_ERROR, "Close Exercise")));
}
diff --git a/src/traffic_quic/quic_client.h b/src/traffic_quic/quic_client.h
index 0e3e534..9cd7573 100644
--- a/src/traffic_quic/quic_client.h
+++ b/src/traffic_quic/quic_client.h
@@ -30,12 +30,14 @@
#include "QUICApplication.h"
+// TODO: add quic version option
struct QUICClientConfig {
char addr[1024] = "127.0.0.1";
char output[1024] = {0};
char port[16] = "4433";
char path[1018] = "/";
char debug_tags[1024] = "quic";
+ int close = false;
};
class QUICClient : public Continuation
@@ -55,11 +57,12 @@ private:
class QUICClientApp : public QUICApplication
{
public:
- QUICClientApp(QUICNetVConnection *qvc, const char *filename);
+ QUICClientApp(QUICNetVConnection *qvc, const QUICClientConfig *config);
void start(const char *path);
int main_event_handler(int event, Event *data);
private:
- const char *_filename = nullptr;
+ const QUICClientConfig *_config = nullptr;
+ const char *_filename = nullptr;
};
diff --git a/src/traffic_quic/traffic_quic.cc b/src/traffic_quic/traffic_quic.cc
index ec81a45..67802af 100644
--- a/src/traffic_quic/traffic_quic.cc
+++ b/src/traffic_quic/traffic_quic.cc
@@ -57,6 +57,7 @@ main(int argc, const char **argv)
{"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},
+ {"close", 'c', "Enable connection close excercise", "F", &config.close,
nullptr, nullptr},
HELP_ARGUMENT_DESCRIPTION(),
VERSION_ARGUMENT_DESCRIPTION(),
RUNROOT_ARGUMENT_DESCRIPTION(),