diff --git a/repos/ports/ports/netperf.hash b/repos/ports/ports/netperf.hash index b3f3bf65a0..7326120286 100644 --- a/repos/ports/ports/netperf.hash +++ b/repos/ports/ports/netperf.hash @@ -1 +1 @@ -6db34a7949b8942c256b881977e91fbf53638dd6 +56f2157a43b51cb0a534f251187dbc00038b276a diff --git a/repos/ports/src/app/netperf/netlib.patch b/repos/ports/src/app/netperf/netlib.patch index f99cd1a929..d572e213b6 100644 --- a/repos/ports/src/app/netperf/netlib.patch +++ b/repos/ports/src/app/netperf/netlib.patch @@ -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. */ diff --git a/repos/ports/src/app/netperf/omni.patch b/repos/ports/src/app/netperf/omni.patch index 56747cba66..47c2091edf 100644 --- a/repos/ports/src/app/netperf/omni.patch +++ b/repos/ports/src/app/netperf/omni.patch @@ -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 diff --git a/repos/ports/src/app/netperf/target.mk b/repos/ports/src/app/netperf/target.mk index cae4fa29c3..b2b5baa808 100644 --- a/repos/ports/src/app/netperf/target.mk +++ b/repos/ports/src/app/netperf/target.mk @@ -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 : diff --git a/repos/ports/src/app/netperf/timer.cc b/repos/ports/src/app/netperf/timer.cc deleted file mode 100644 index 6121ceea29..0000000000 --- a/repos/ports/src/app/netperf/timer.cc +++ /dev/null @@ -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 -#include -#include - -/* 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); -}