Kouhei Sutou
null+****@clear*****
Sun Mar 13 11:55:09 JST 2016
Kouhei Sutou 2016-03-13 11:55:09 +0900 (Sun, 13 Mar 2016) New Revision: 8841a8bc426eed93454b5cf7c2042c5a5a590dd2 https://github.com/groonga/groonga/commit/8841a8bc426eed93454b5cf7c2042c5a5a590dd2 Message: grn_ctx_recv: return remained buffer data even if quitting This change enables response by shutdown command. Modified files: lib/ctx.c Modified: lib/ctx.c (+22 -6) =================================================================== --- lib/ctx.c 2016-03-11 18:38:45 +0900 (0c8bff4) +++ lib/ctx.c 2016-03-13 11:55:09 +0900 (c675e8d) @@ -1732,12 +1732,26 @@ unsigned int grn_ctx_recv(grn_ctx *ctx, char **str, unsigned int *str_len, int *flags) { if (!ctx) { return GRN_INVALID_ARGUMENT; } + + *flags = 0; + if (ctx->stat == GRN_CTX_QUIT) { - *str = NULL; - *str_len = 0; - *flags = GRN_CTX_QUIT; - return 0; + grn_bool have_buffer = GRN_FALSE; + + if (ctx->impl && + !ctx->impl->com && + GRN_TEXT_LEN(ctx->impl->output.buf) > 0) { + have_buffer = GRN_TRUE; + } + + *flags |= GRN_CTX_QUIT; + if (!have_buffer) { + *str = NULL; + *str_len = 0; + return 0; + } } + GRN_API_ENTER; if (ctx->impl) { if (ctx->impl->com) { @@ -1751,9 +1765,11 @@ grn_ctx_recv(grn_ctx *ctx, char **str, unsigned int *str_len, int *flags) *str_len = GRN_BULK_VSIZE(ctx->impl->output.buf); if (header.flags & GRN_CTX_QUIT) { ctx->stat = GRN_CTX_QUIT; - *flags = GRN_CTX_QUIT; + *flags |= GRN_CTX_QUIT; } else { - *flags = (header.flags & GRN_CTX_TAIL) ? 0 : GRN_CTX_MORE; + if (!(header.flags & GRN_CTX_TAIL)) { + *flags |= GRN_CTX_MORE; + } } ctx->impl->output.type = header.qtype; ctx->rc = (int16_t)ntohs(header.status); -------------- next part -------------- HTML����������������������������...下载