From 9f2097669a82746de2ca8a7ef77c0b12219c32d2 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 25 Jun 2013 17:11:36 +0200 Subject: [PATCH] netperf: add support to timeout if host went away --- ports/src/app/netperf/omni.patch | 29 +++++++++++++++++++++++++++++ ports/src/app/netperf/timer.patch | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ports/src/app/netperf/omni.patch b/ports/src/app/netperf/omni.patch index 6149771af..afd95fc9f 100644 --- a/ports/src/app/netperf/omni.patch +++ b/ports/src/app/netperf/omni.patch @@ -48,6 +48,35 @@ Index: src/nettest_omni.c int timed_out = 0; int pad_time = 0; +@@ -5312,6 +5312,28 @@ + 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 Index: src/nettest_bsd.h =================================================================== --- src/nettest_bsd.h (revision 644) diff --git a/ports/src/app/netperf/timer.patch b/ports/src/app/netperf/timer.patch index 5411880cb..af5672c4f 100644 --- a/ports/src/app/netperf/timer.patch +++ b/ports/src/app/netperf/timer.patch @@ -5,7 +5,7 @@ extern void dump_addrinfo(FILE *dumploc, struct addrinfo *info, char *host, char *port, int family); +#ifdef GENODE_BUILD -+static inline void start_timer(int time) { printf("%s: not supported\n", __FUNCTION__);} ++static inline void start_timer(int time) { } +#else extern void start_timer(int time); +#endif