Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run without itimer support in alpine #143

Open
wants to merge 5 commits into
base: sockperf_v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
28 changes: 28 additions & 0 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

TicksTime s_startTime, s_endTime;

#ifdef NO_SETITIMERS_SYSCALL
pthread_t parent;
#endif

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

Expand Down Expand Up @@ -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 <class IoType, class SwitchDataIntegrity, class SwitchActivityInfo,
class SwitchCycleDuration, class SwitchMsgSize, class PongModeCare>
Expand Down Expand Up @@ -637,12 +655,22 @@ int Client<IoType, SwitchDataIntegrity, SwitchActivityInfo, SwitchCycleDuration,
log_msg("Starting test...");

if (!g_pApp->m_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) {
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