diff --git a/src/client.cpp b/src/client.cpp index a355089e..0ae36340 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -35,6 +35,10 @@ TicksTime s_startTime, s_endTime; +#ifdef NO_SETITIMERS_SYSCALL + pthread_t parent; +#endif + //============================================================================== //============================================================================== @@ -524,6 +528,20 @@ static int _connect_check(int ifd) { return rc; } +#ifdef NO_SETITIMERS_SYSCALL +void* thread_sleep(void* args) +{ + int sec = (g_pApp->m_const_params.cooldown_msec + g_pApp->m_const_params.warmup_msec) / 1000 + + g_pApp->m_const_params.sec_test_duration; + int usec = (g_pApp->m_const_params.cooldown_msec + g_pApp->m_const_params.warmup_msec) % 1000; + log_msg("Start sleep for %d seconds %d useconds", sec, usec); + sleep(sec); + usleep(usec); + pthread_kill(parent, SIGUSR1); + return NULL; +} +#endif + //------------------------------------------------------------------------------ template @@ -637,12 +655,22 @@ int Clientm_const_params.pPlaybackVector) { + #ifndef NO_SETITIMERS_SYSCALL struct itimerval timer; set_client_timer(&timer); if (os_set_duration_timer(timer, client_sig_handler)) { log_err("Failed setting test duration timer"); rc = SOCKPERF_ERR_FATAL; } + #else + parent = pthread_self(); + os_set_signal_action(SIGUSR1, client_sig_handler); + + os_thread_t thread; + os_thread_init(&thread); + os_thread_exec(&thread, thread_sleep, NULL); + os_thread_detach(&thread); + #endif } if (rc == SOCKPERF_ERR_NONE) { diff --git a/src/ticks.h b/src/ticks.h index 3bf932ad..69169ef7 100644 --- a/src/ticks.h +++ b/src/ticks.h @@ -103,6 +103,7 @@ with simple integral values. The following describes these calculations: #endif #include "ticks_os.h" +#include "os_abstract.h" // usefull constants static const int64_t USEC_IN_SEC = 1000 * 1000; diff --git a/src/vma-redirect.h b/src/vma-redirect.h index 2467bef0..aed846aa 100644 --- a/src/vma-redirect.h +++ b/src/vma-redirect.h @@ -33,7 +33,8 @@ #include #include #include -#include +#include +#include #include #include