From 544ca6db466ee6c5647ac945e87ec5a6f9fbe249 Mon Sep 17 00:00:00 2001 From: Robert Izzard <r.izzard@surrey.ac.uk> Date: Wed, 20 Nov 2019 11:13:44 +0800 Subject: [PATCH] update reset_timeout to not call setitimer if TIMEOUT_SECONDS is zero : this isn't required because no timeout will ever have been set --- src/reset_timeout.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/reset_timeout.c b/src/reset_timeout.c index 47c8da58e..fa8c209ac 100644 --- a/src/reset_timeout.c +++ b/src/reset_timeout.c @@ -60,18 +60,21 @@ void reset_binary_c_timeout(void) void disable_binary_c_timeout(void) { -#ifdef LINUX - struct itimerval value; - struct timeval tv; - tv.tv_sec=0; /* 0 disables the timer */ - tv.tv_usec=0; - value.it_value=tv; - value.it_interval=tv; - - if(setitimer(ITIMER_VIRTUAL,&value,0) == -1) +#ifdef LINUX + if(TIMEOUT_SECONDS) { - Exit_binary_c_no_stardata(BINARY_C_TIMED_OUT, - "Failed to allocate virtual timer"); + struct itimerval value; + struct timeval tv; + tv.tv_sec=0; /* 0 disables the timer */ + tv.tv_usec=0; + value.it_value=tv; + value.it_interval=tv; + + if(setitimer(ITIMER_VIRTUAL,&value,0) == -1) + { + Exit_binary_c_no_stardata(BINARY_C_TIMED_OUT, + "Failed to allocate virtual timer"); + } } -#endif +#endif // LINUX } -- GitLab