netperf: retire signal patches and setitimer

emulation. Issue #5337 adds the required support to the libc.
This commit is contained in:
Alexander Boettcher 2024-09-02 08:50:10 +02:00 committed by Christian Helmuth
parent fc3bd14da0
commit e2dd009256
5 changed files with 3 additions and 138 deletions

View File

@ -1 +1 @@
6db34a7949b8942c256b881977e91fbf53638dd6
56f2157a43b51cb0a534f251187dbc00038b276a

View File

@ -1,28 +1,3 @@
+++ src/app/netperf/src/netlib.c
@@ -1095,8 +1095,13 @@
#endif /* WIN32 */
+#ifdef GENODE_BUILD
+void
+start_do_not_use_timer(int time)
+#else
void
start_timer(int time)
+#endif
{
#ifdef WIN32
@@ -3059,7 +3063,9 @@
(which == SEND_BUFFER) ? "SO_SNDBUF" : "SO_RCVBUF",
errno);
fflush(where);
+#ifndef GENODE_BUILD
exit(1);
+#endif
}
if (debug > 1) {
fprintf(where, "netperf: set_sock_buffer: %s of %d requested.\n",
+++ src/app/netperf/src/netlib.h
@@ -368,7 +368,7 @@
/* Let's define a macro to hide all of this. */

View File

@ -83,32 +83,3 @@ index 826167a..3c10d0a 100644
int timed_out = 0;
int pad_time = 0;
@@ -5312,6 +5312,28 @@ recv_omni()
need_to_accept = 0;
connected = 1;
+#ifdef GENODE_BUILD
+ /*
+ * We don't support setitimer which uses signals. Instead set timeouts on
+ * the send and recv socket functions to be able to terminate if the host
+ * went away.
+ */
+ struct timeval timeout;
+ /* XXX LWIP expect ms instead of seconds */
+ timeout.tv_sec = 10 * 1000;
+ timeout.tv_usec = 0;
+
+ int sock_error = setsockopt(data_socket, SOL_SOCKET, SO_SNDTIMEO, &timeout,
+ sizeof(timeout));
+ if (sock_error)
+ fprintf(where, "could not send timeout for send - test may not terminate\n");
+
+ sock_error = setsockopt(data_socket, SOL_SOCKET, SO_RCVTIMEO, &timeout,
+ sizeof(timeout));
+ if (sock_error)
+ fprintf(where, "could not send timeout for recv - test may not terminate\n");
+#endif
+
#ifdef KLUDGE_SOCKET_OPTIONS
/* this is for those systems which *INCORRECTLY* fail to pass
attributes across an accept() call. Including this goes

View File

@ -9,17 +9,14 @@ SRC_C = netserver.c netlib.c netsh.c nettest_bsd.c dscp.c
SRC_C += nettest_omni.c net_uuid.c
SRC_C += netsys_none.c netsec_none.c netdrv_none.c netrt_none.c netslot_none.c netcpu_none.c
SRC_CC += timer.cc
INC_DIR += $(PRG_DIR)
CC_OPT += -DHAVE_CONFIG_H -DGENODE_BUILD
CC_OPT += -DHAVE_CONFIG_H
CC_WARN = -Wall -Wno-unused -Wno-maybe-uninitialized -Wno-format-truncation \
-Wno-stringop-truncation -Wno-stringop-overflow
CC_CXX_WARN_STRICT =
vpath timer.cc $(PRG_DIR)
vpath %.c $(NETPERF_DIR)/src
vpath %.c $(NETPERF_DIR)/src
# vi: set ft=make :

View File

@ -1,78 +0,0 @@
/*
* \brief Timeout handling for netperf, based on test/alarm
* \author Alexander Boettcher
* \date 2014-01-10
*/
/*
* Copyright (C) 2014-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#include <pthread.h>
#include <unistd.h>
#include <base/log.h>
/* defined in "ports/contrib/netperf/src/netlib.c" */
extern "C" int times_up;
namespace {
struct Timer_thread
{
pthread_t _pthread { };
pthread_attr_t _attr { };
pthread_mutex_t _mutex { PTHREAD_MUTEX_INITIALIZER };
int _seconds_left = 0;
void _entry()
{
for (;;) {
sleep(1);
pthread_mutex_lock(&_mutex);
if (_seconds_left) {
--_seconds_left;
if (_seconds_left == 0) {
times_up = true;
}
}
pthread_mutex_unlock(&_mutex);
}
}
static void *_entry(void *arg)
{
Timer_thread &myself = *(Timer_thread *)arg;
myself._entry();
return nullptr;
}
Timer_thread()
{
pthread_mutex_init(&_mutex, nullptr);
pthread_create(&_pthread, &_attr, _entry, this);
}
void schedule_timeout(int seconds)
{
pthread_mutex_lock(&_mutex);
times_up = false;
_seconds_left = seconds;
pthread_mutex_unlock(&_mutex);
}
};
}
extern "C" void
start_timer(int time)
{
static Timer_thread timer_thread { };
timer_thread.schedule_timeout(time);
}