From b41ed8f8cbbdf7cff415f69f6f9b4a92cfe1f37d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Mon, 30 May 2016 12:51:17 +0200 Subject: [PATCH] applies timeout setting for apis MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I6ff93946990400a6e900d6d6916e2b68af92fbcc Signed-off-by: José Bollo --- src/afb-api-so.c | 5 +++++ src/afb-api-so.h | 2 ++ src/afb-config.h | 2 +- src/main.c | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/afb-api-so.c b/src/afb-api-so.c index 9756b0e0..b741b13a 100644 --- a/src/afb-api-so.c +++ b/src/afb-api-so.c @@ -53,6 +53,11 @@ static int api_timeout = 15; static const char plugin_register_function_v1[] = "pluginAfbV1Register"; +void afb_api_so_set_timeout(int to) +{ + api_timeout = to; +} + static int afb_api_so_event_broadcast(struct api_so_desc *desc, const char *name, struct json_object *object) { size_t length; diff --git a/src/afb-api-so.h b/src/afb-api-so.h index 8ef58a53..143b7a05 100644 --- a/src/afb-api-so.h +++ b/src/afb-api-so.h @@ -18,6 +18,8 @@ #pragma once +extern void afb_api_so_set_timeout(int to); + extern int afb_api_so_add_plugin(const char *path); extern int afb_api_so_add_directory(const char *path); diff --git a/src/afb-config.h b/src/afb-config.h index c0def7c8..5fe87c65 100644 --- a/src/afb-config.h +++ b/src/afb-config.h @@ -24,7 +24,7 @@ #define MAX_ALIAS 10 // max number of aliases #define DEFLT_CNTX_TIMEOUT 3600 // default Client Connection Timeout -#define DEFLT_API_TIMEOUT 0 // default Plugin API Timeout [0=NoLimit for Debug Only] +#define DEFLT_API_TIMEOUT 20 // default Plugin API Timeout [0=NoLimit for Debug Only] #define DEFLT_CACHE_TIMEOUT 100000 // default Static File Chache [Client Side Cache 100000~=1day] #define DEFLT_AUTH_TOKEN NULL // expect for debug should == NULL #define DEFLT_HTTP_TIMEOUT 15 // Max MibMicroHttp timeout diff --git a/src/main.c b/src/main.c index defab848..54cd6f6d 100644 --- a/src/main.c +++ b/src/main.c @@ -585,6 +585,7 @@ int main(int argc, char *argv[]) { exit (1); } + afb_api_so_set_timeout(config->apiTimeout); if (config->ldpaths) { if (afb_api_so_add_pathset(config->ldpaths) < 0) { ERROR("initialisation of plugins within %s failed", config->ldpaths); -- 2.16.6