aboutsummaryrefslogtreecommitdiffstats
path: root/fnet
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-01-14 08:50:46 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-01-14 08:50:46 +0000
commitdb55a4ea1ec4976aced4bae0b4bb5b27684b1e71 (patch)
tree8af3b98be114b1a4ef3afcfa1a9a4a34e28e03bc /fnet
parent94aa4e270540c078d20e75effa3d482fb2f034a8 (diff)
Reduce timeouts.
Diffstat (limited to 'fnet')
-rw-r--r--fnet/src/examples/ping/pingclient.cpp9
-rw-r--r--fnet/src/examples/timeout/timeout.cpp12
-rw-r--r--fnet/src/tests/examples/examples_test.cpp13
3 files changed, 20 insertions, 14 deletions
diff --git a/fnet/src/examples/ping/pingclient.cpp b/fnet/src/examples/ping/pingclient.cpp
index 6a7bd21e715..afd2475bfa0 100644
--- a/fnet/src/examples/ping/pingclient.cpp
+++ b/fnet/src/examples/ping/pingclient.cpp
@@ -22,7 +22,7 @@ int
PingClient::Main()
{
if (_argc < 2) {
- printf("usage : pingclient <connectspec>\n");
+ printf("usage : pingclient <connectspec> <timeout>\n");
printf("example: pingclient 'tcp/localhost:8000'\n");
return 1;
}
@@ -33,7 +33,12 @@ PingClient::Main()
FNET_SimplePacketStreamer streamer(&factory);
FNET_Transport transport;
FNET_Connection *conn = transport.Connect(_argv[1], &streamer);
+ uint32_t timeout_ms=5000;
FNET_Channel *channels[10];
+
+ if (_argc == 3) {
+ timeout_ms = atof(_argv[2]) * 1000;
+ }
transport.Start(&pool);
uint32_t channelCnt = 0;
@@ -52,7 +57,7 @@ PingClient::Main()
FNET_Packet *packet;
FNET_Context context;
while (channelCnt > 0) {
- packet = queue.DequeuePacket(5000, &context);
+ packet = queue.DequeuePacket(timeout_ms, &context);
if (packet == nullptr) {
fprintf(stderr, "Timeout\n");
for(int c = 0; c < 10; c++) {
diff --git a/fnet/src/examples/timeout/timeout.cpp b/fnet/src/examples/timeout/timeout.cpp
index 9f363ccd864..b2f6c3a8e3c 100644
--- a/fnet/src/examples/timeout/timeout.cpp
+++ b/fnet/src/examples/timeout/timeout.cpp
@@ -60,16 +60,16 @@ MyApp::Main()
transport.Start(&pool);
// stable-state operation
- std::this_thread::sleep_for(500ms);
+ std::this_thread::sleep_for(100ms);
FNET_Packet *packet;
FNET_Context context;
- fprintf(stderr, "scheduling timeout in 2 seconds...\n");
+ fprintf(stderr, "scheduling timeout in 1 seconds...\n");
t = clock::now();
- timeout.Schedule(2.0); // timeout in 2 seconds
+ timeout.Schedule(1.0); // timeout in 1 seconds
- std::this_thread::sleep_for(1s);
+ std::this_thread::sleep_for(100ms);
timeout.Unschedule(); // cancel timeout
ms = (clock::now() - t);
@@ -78,9 +78,9 @@ MyApp::Main()
fprintf(stderr, "timeout canceled; no timeout packet delivered\n");
fprintf(stderr, "time since timeout was scheduled: %f ms\n", ms.count());
- fprintf(stderr, "scheduling timeout in 2 seconds...\n");
+ fprintf(stderr, "scheduling timeout in 1 seconds...\n");
t = clock::now();
- timeout.Schedule(2.0); // timeout in 2 seconds
+ timeout.Schedule(1.0); // timeout in 1 seconds
packet = queue.DequeuePacket(&context); // wait for timeout
ms = (clock::now() - t);
diff --git a/fnet/src/tests/examples/examples_test.cpp b/fnet/src/tests/examples/examples_test.cpp
index 8f13aca0898..0496c5a9de8 100644
--- a/fnet/src/tests/examples/examples_test.cpp
+++ b/fnet/src/tests/examples/examples_test.cpp
@@ -115,13 +115,14 @@ TEST_MT_F("ping", 2, std::atomic<bool>()) {
TEST_MT_F("ping times out", 2, std::atomic<bool>()) {
if (thread_id == 0) {
ChildProcess proc(vespalib::make_string("exec ../../examples/frt/rpc/fnet_rpc_server_app tcp/%d",
- PORT0).c_str());
+ PORT0).c_str());
TEST_BARRIER();
EXPECT_TRUE(runProc(proc, f1));
} else {
+ float timeout_s = 0.1;
TEST_BARRIER();
- EXPECT_TRUE(runProc(vespalib::make_string("exec ../../examples/ping/fnet_pingclient_app tcp/localhost:%d",
- PORT0).c_str()));
+ EXPECT_TRUE(runProc(vespalib::make_string("exec ../../examples/ping/fnet_pingclient_app tcp/localhost:%d %f",
+ PORT0, timeout_s).c_str()));
f1 = true;
}
}
@@ -129,12 +130,12 @@ TEST_MT_F("ping times out", 2, std::atomic<bool>()) {
TEST_MT_F("ping with proxy", 3, std::atomic<bool>()) {
if (thread_id == 0) {
ChildProcess proc(vespalib::make_string("exec ../../examples/ping/fnet_pingserver_app tcp/%d",
- PORT0).c_str());
+ PORT0).c_str());
TEST_BARRIER();
EXPECT_TRUE(runProc(proc, f1));
} else if (thread_id == 1) {
ChildProcess proc(vespalib::make_string("exec ../../examples/proxy/fnet_proxy_app tcp/%d tcp/localhost:%d",
- PORT1, PORT0).c_str());
+ PORT1, PORT0).c_str());
TEST_BARRIER();
EXPECT_TRUE(runProc(proc, f1));
} else {
@@ -148,7 +149,7 @@ TEST_MT_F("ping with proxy", 3, std::atomic<bool>()) {
TEST_MT_F("rpc client server", 2, std::atomic<bool>()) {
if (thread_id == 0) {
ChildProcess proc(vespalib::make_string("exec ../../examples/frt/rpc/fnet_rpc_server_app tcp/%d",
- PORT0).c_str());
+ PORT0).c_str());
TEST_BARRIER();
EXPECT_TRUE(runProc(proc, f1));
} else {