Skip to content

Commit fb191bd

Browse files
committed
ddsperf option for stopping when no peers remain
Signed-off-by: Erik Boasson <[email protected]>
1 parent 1699cd7 commit fb191bd

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/ddsrt/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ set(source_dir "${CMAKE_CURRENT_SOURCE_DIR}")
2727
set(binary_dir "${CMAKE_CURRENT_BINARY_DIR}")
2828

2929
add_library(ddsrt INTERFACE)
30+
if(ENABLE_MIMALLOC)
31+
target_link_libraries(ddsrt INTERFACE mimalloc)
32+
endif()
3033
target_include_directories(
3134
ddsrt INTERFACE
3235
"$<BUILD_INTERFACE:${source_dir}/include>"
@@ -368,7 +371,7 @@ set(DDSRT_WITH_LWIP ${WITH_LWIP})
368371
set(DDSRT_WITH_FREERTOS ${WITH_FREERTOS})
369372

370373
foreach(feature TCP_TLS SECURITY LIFESPAN DEADLINE_MISSED NETWORK_PARTITIONS
371-
TYPELIB TYPE_DISCOVERY TOPIC_DISCOVERY QOS_PROVIDER)
374+
TYPELIB TYPE_DISCOVERY TOPIC_DISCOVERY QOS_PROVIDER MIMALLOC)
372375
set(DDS_HAS_${feature} ${ENABLE_${feature}})
373376
endforeach()
374377

src/tools/ddsperf/ddsperf.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ static bool sublatency = false;
191191
/* Use writer loans (only for memcpy-able types) */
192192
static bool use_writer_loan = false;
193193

194+
/* Stop when no peers remain */
195+
static bool stop_when_lonely = false;
196+
194197
/* Event queue for processing discovery events (data available on
195198
DCPSParticipant, subscription & publication matched)
196199
asynchronously to avoid deadlocking on creating a reader from
@@ -1919,6 +1922,7 @@ OPTIONS:\n\
19191922
from -Qmaxwait:DUR because that doesn't delay starting\n\
19201923
and doesn't terminate the process before doing\n\
19211924
anything.)\n\
1925+
-0 stop when no peers remain\n\
19221926
-1 print \"sub\" stats every second, even when there is\n\
19231927
data\n\
19241928
-X output extended statistics\n\
@@ -2263,11 +2267,12 @@ int main (int argc, char *argv[])
22632267

22642268
argv0 = argv[0];
22652269

2266-
while ((opt = getopt (argc, argv, "1cd:D:i:n:k:ulLK:T:Q:R:Xh")) != EOF)
2270+
while ((opt = getopt (argc, argv, "01cd:D:i:n:k:ulLK:T:Q:R:Xh")) != EOF)
22672271
{
22682272
int pos;
22692273
switch (opt)
22702274
{
2275+
case '0': stop_when_lonely = true; break;
22712276
case '1': substat_every_second = true; break;
22722277
case 'c': collect_stats = true; break;
22732278
case 'd': {
@@ -2729,6 +2734,11 @@ int main (int argc, char *argv[])
27292734
{
27302735
twakeup = pp->tdeadline;
27312736
}
2737+
if (stop_when_lonely && ddsrt_avl_is_singleton (&ppants) && matchcount > 0)
2738+
{
2739+
// last peer left
2740+
ddsrt_atomic_st32 (&termflag, 1);
2741+
}
27322742
ddsrt_mutex_unlock (&disc_lock);
27332743
}
27342744

0 commit comments

Comments
 (0)