summaryrefslogtreecommitdiff
path: root/src/c/urweb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/urweb.c')
-rw-r--r--src/c/urweb.c16
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");
+}