Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@

TicksTime s_startTime, s_endTime;

#ifdef NO_TIMERS
pthread_t parent;
struct itimerval timer;
#endif

//==============================================================================
//==============================================================================

Expand Down Expand Up @@ -524,6 +529,17 @@ static int _connect_check(int ifd) {
return rc;
}

#ifdef NO_TIMERS
void* thread_sleep(void* args)
{
// struct itimerval *temp_timer = (struct itimerval *) args;
log_msg("Start sleep for %d seconds", (int)((struct itimerval *)args)->it_value.tv_sec);
sleep(((struct itimerval *)args)->it_value.tv_sec);
pthread_kill(parent, SIGUSR1);
return NULL;
}
#endif

//------------------------------------------------------------------------------
template <class IoType, class SwitchDataIntegrity, class SwitchActivityInfo,
class SwitchCycleDuration, class SwitchMsgSize, class PongModeCare>
Expand Down Expand Up @@ -637,12 +653,23 @@ int Client<IoType, SwitchDataIntegrity, SwitchActivityInfo, SwitchCycleDuration,
log_msg("Starting test...");

if (!g_pApp->m_const_params.pPlaybackVector) {
#ifndef NO_TIMERS
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
set_client_timer(&timer);
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, &timer);
os_thread_detach(&thread);
#endif
}

if (rc == SOCKPERF_ERR_NONE) {
Expand Down
1 change: 1 addition & 0 deletions src/ticks.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ with simple integral values. The following describes these calculations:
#endif

#include "ticks_os.h"
#include "os_abstract.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I see that you use os_thread_t in file client.cpp. Why not include header os_abstract.h in client.h?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the changes required to properly build in alpine OS, the program was not able to find this file


// usefull constants
static const int64_t USEC_IN_SEC = 1000 * 1000;
Expand Down
3 changes: 2 additions & 1 deletion src/vma-redirect.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/poll.h>
#include <stdio.h>
Copy link
Contributor

@ChrisCoe ChrisCoe Feb 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is stdio.h being included to vma-redirect.h when vma-redirect.cpp has not been touched? Not clear to me.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, this is another change required to build sockperf in alpine OS

#include <poll.h>
#include <sched.h>
#include <sys/ioctl.h>

Expand Down