Kouhei Sutou
null+****@clear*****
Wed Apr 6 12:40:09 JST 2016
Kouhei Sutou 2016-04-06 12:40:09 +0900 (Wed, 06 Apr 2016) New Revision: 97923dfc7f82f58c713d8d315fa428f54db99395 https://github.com/groonga/groonga/commit/97923dfc7f82f58c713d8d315fa428f54db99395 Message: Support setting the default request timeout New APIs: * grn_get_default_request_timeout() * grn_set_default_request_timeout() TODO: Document them. Modified files: include/groonga/request_timer.h lib/ctx.c lib/request_timer.c Modified: include/groonga/request_timer.h (+4 -0) =================================================================== --- include/groonga/request_timer.h 2016-04-06 12:22:54 +0900 (c9fa499) +++ include/groonga/request_timer.h 2016-04-06 12:40:09 +0900 (ccc093b) @@ -44,6 +44,10 @@ GRN_API void *grn_request_timer_register(const char *request_id, GRN_API void grn_request_timer_unregister(void *timer_id); +GRN_API double grn_get_default_request_timeout(void); +GRN_API void grn_set_default_request_timeout(double timeout); + + #ifdef __cplusplus } #endif Modified: lib/ctx.c (+6 -2) =================================================================== --- lib/ctx.c 2016-04-06 12:22:54 +0900 (11fc74f) +++ lib/ctx.c 2016-04-06 12:40:09 +0900 (3ee1e15) @@ -1459,10 +1459,11 @@ grn_ctx_qe_exec_uri(grn_ctx *ctx, const char *path, uint32_t path_len) grn_command_version command_version; grn_obj buf, *expr, *val; grn_obj request_id; - double request_timeout = 0.0; + double request_timeout; const char *p = path, *e = path + path_len, *v, *key_end, *filename_end; command_version = grn_ctx_get_command_version(ctx); + request_timeout = grn_get_default_request_timeout(); GRN_TEXT_INIT(&buf, 0); GRN_TEXT_INIT(&request_id, 0); @@ -1570,9 +1571,12 @@ grn_ctx_qe_exec(grn_ctx *ctx, const char *str, uint32_t str_len) int offset = 0; grn_obj buf, *expr = NULL, *val = NULL; grn_obj request_id; - double request_timeout = 0.0; + double request_timeout; const char *p = str, *e = str + str_len, *v; + command_version = grn_ctx_get_command_version(ctx); + request_timeout = grn_get_default_request_timeout(); + GRN_TEXT_INIT(&buf, 0); GRN_TEXT_INIT(&request_id, 0); p = grn_text_unesc_tok(ctx, &buf, p, e, &tok_type); Modified: lib/request_timer.c (+13 -0) =================================================================== --- lib/request_timer.c 2016-04-06 12:22:54 +0900 (572f545) +++ lib/request_timer.c 2016-04-06 12:40:09 +0900 (9a5d85f) @@ -20,6 +20,7 @@ #include "grn_request_timer.h" static grn_request_timer grn_current_request_timer = { 0 }; +static double grn_request_timer_default_timeout = 0.0; grn_bool grn_request_timer_init(void) @@ -68,6 +69,18 @@ grn_request_timer_set(grn_request_timer *timer) } } +double +grn_get_default_request_timeout(void) +{ + return grn_request_timer_default_timeout; +} + +void +grn_set_default_request_timeout(double timeout) +{ + grn_request_timer_default_timeout = timeout; +} + void grn_request_timer_fin(void) { -------------- next part -------------- HTML����������������������������...다운로드