diff options
| author | J08nY | 2017-10-04 19:09:20 +0200 |
|---|---|---|
| committer | J08nY | 2017-10-04 19:09:20 +0200 |
| commit | f708453b55b6b05187febf3d5a2bd8608a897370 (patch) | |
| tree | 340d36ad38ae355aa606820e5a1c045df977cbec /src/util/timeout.h | |
| parent | caa000e3625241b930fdcda1594bbaf9c9acf642 (diff) | |
| download | ecgen-f708453b55b6b05187febf3d5a2bd8608a897370.tar.gz ecgen-f708453b55b6b05187febf3d5a2bd8608a897370.tar.zst ecgen-f708453b55b6b05187febf3d5a2bd8608a897370.zip | |
Add per-param timeout option.
Diffstat (limited to 'src/util/timeout.h')
| -rw-r--r-- | src/util/timeout.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/util/timeout.h b/src/util/timeout.h index 0226fda..2b615bb 100644 --- a/src/util/timeout.h +++ b/src/util/timeout.h @@ -16,8 +16,11 @@ extern __thread sigjmp_buf timeout_ptr; extern __thread bool timeout_in; extern __thread timer_t timeout_timer; +/** + * @brief + */ #define timeout_start(seconds) \ - { \ + if ((seconds) != 0) { \ struct sigevent sevp; \ sevp.sigev_notify = SIGEV_THREAD_ID; \ sevp.sigev_signo = SIGALRM; \ @@ -30,12 +33,17 @@ extern __thread timer_t timeout_timer; timer_settime(timeout_timer, 0, &timer_time, NULL); \ timeout_in = true; \ }; \ - if (sigsetjmp(timeout_ptr, 1) == 1) + if ((seconds) != 0 && sigsetjmp(timeout_ptr, 1) == 1) -#define timeout_stop() \ - { \ - timeout_in = false; \ - timer_delete(timeout_timer); \ +/** + * @brief + */ +#define timeout_stop() \ + { \ + if (timeout_in) { \ + timeout_in = false; \ + timer_delete(timeout_timer); \ + } \ } /** |
