From f0b11dadf14c4ca347534f397e81155fe2795b2b Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Tue, 2 Oct 2012 23:01:57 +0200 Subject: [PATCH] Refurbished adcrush (hub stress tester). --- CMakeLists.txt | 9 ++++++++- src/tools/adcrush.c | 9 +++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65747bb..ab741cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ option(RELEASE "Release build, debug build if disabled" ON) option(LINK_SUPPORT "Allow hub linking" OFF) option(SSL_SUPPORT "Enable SSL support" ON) option(SQLITE_SUPPORT "Enable SQLite support" ON) +option(ADC_STRESS "Enable the stress tester client" OFF) find_package(Git) @@ -137,8 +138,13 @@ target_link_libraries(uhub ${CMAKE_DL_LIBS} adc network utils) if(UNIX) add_library(adcclient STATIC ${adcclient_SOURCES}) - add_executable(uhub-admin ${PROJECT_SOURCE_DIR}/tools/admin.c ${adcclient_SOURCES}) + add_executable(uhub-admin ${PROJECT_SOURCE_DIR}/tools/admin.c) target_link_libraries(uhub-admin adcclient adc network utils) + + if (ADC_STRESS) + add_executable(adcrush ${PROJECT_SOURCE_DIR}/tools/adcrush.c ${adcclient_SOURCES}) + target_link_libraries(adcrush adcclient adc network utils) + endif() endif() if(GIT_FOUND AND IS_DIRECTORY ".git") @@ -166,6 +172,7 @@ if (RELEASE) set(CMAKE_BUILD_TYPE Release) else() set(CMAKE_BUILD_TYPE Debug) + add_definitions(-DDEBUG) endif() diff --git a/src/tools/adcrush.c b/src/tools/adcrush.c index b1e894d..88370bc 100644 --- a/src/tools/adcrush.c +++ b/src/tools/adcrush.c @@ -331,13 +331,10 @@ void runloop(size_t clients) for (n = 0; n < clients; n++) { - struct ADC_client* c = malloc(sizeof(struct ADC_client)); - client[n] = c; - char nick[20]; snprintf(nick, 20, "adcrush_%d", (int) n); - - ADC_client_create(c, nick, "stresstester"); + struct ADC_client* c = ADC_client_create(nick, "stresstester"); + client[n] = c; ADC_client_set_callback(c, handle); ADC_client_connect(c, cfg_uri); } @@ -357,7 +354,7 @@ void runloop(size_t clients) static void print_version() { printf(ADCRUSH "\n"); - printf("Copyright (C) 2008-2009, Jan Vidar Krey\n"); + printf("Copyright (C) 2008-2012, Jan Vidar Krey\n"); printf("\n"); }