diff options
author | Adam Chlipala <adamc@hcoop.net> | 2010-01-03 15:58:34 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2010-01-03 15:58:34 -0500 |
commit | 86bf1a00aacd96b4d32a1e1e88822a2201594926 (patch) | |
tree | eeb16371c114308e706d86c6f9a03ddfbf0fa54f /src/c | |
parent | 6ee843295ea4449a5b8794db6880f8af7aaeff3e (diff) |
Deadlines
Diffstat (limited to 'src/c')
-rw-r--r-- | src/c/urweb.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index a76497bb..27831011 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -9,6 +9,7 @@ #include <stdarg.h> #include <assert.h> #include <ctype.h> +#include <limits.h> #include <stdint.h> #include <sys/types.h> #include <sys/socket.h> @@ -338,6 +339,8 @@ void uw_app_init(uw_app *app) { app->client_init(); } +int uw_time = 0; + // Single-request state @@ -427,6 +430,8 @@ struct uw_context { char *current_url; + int deadline; + char error_message[ERROR_BUF_LEN]; }; @@ -484,6 +489,8 @@ uw_context uw_init() { ctx->current_url = ""; + ctx->deadline = INT_MAX; + return ctx; } @@ -3343,3 +3350,12 @@ uw_Basis_string uw_Basis_currentUrl(uw_context ctx) { void uw_set_currentUrl(uw_context ctx, char *s) { ctx->current_url = s; } + +void uw_set_deadline(uw_context ctx, int n) { + ctx->deadline = n; +} + +void uw_check_deadline(uw_context ctx) { + if (uw_time > ctx->deadline) + uw_error(ctx, FATAL, "Maximum running time exceeded"); +} |