null+****@clear*****
null+****@clear*****
2010年 7月 12日 (月) 19:27:10 JST
Daijiro MORI 2010-07-12 10:27:10 +0000 (Mon, 12 Jul 2010)
New Revision: 1dd0bcac088d55faef38e4da4a6f3ea20d15fc4c
Log:
call grn_timeval_now() in grn_ctx_send() even when acts as client.
Modified files:
lib/ctx.c
src/groonga.c
Modified: lib/ctx.c (+2 -1)
===================================================================
--- lib/ctx.c 2010-07-12 09:45:09 +0000 (3ebb6e7)
+++ lib/ctx.c 2010-07-12 10:27:10 +0000 (99a233c)
@@ -977,6 +977,7 @@ grn_ctx_send(grn_ctx *ctx, const char *str, unsigned int str_len, int flags)
if (ctx->impl->com) {
grn_rc rc;
grn_com_header sheader;
+ grn_timeval_now(ctx, &ctx->impl->tv);
if ((flags & GRN_CTX_MORE)) { flags |= GRN_CTX_QUIET; }
if (ctx->stat == GRN_CTX_QUIT) { flags |= GRN_CTX_QUIT; }
sheader.proto = GRN_COM_PROTO_GQTP;
@@ -1064,7 +1065,7 @@ grn_ctx_recv(grn_ctx *ctx, char **str, unsigned int *str_len, int *flags)
*flags = (header.flags & GRN_CTX_TAIL) ? 0 : GRN_CTX_MORE;
}
ctx->impl->output_type = header.qtype;
- ctx->rc = header.status;
+ ctx->rc = (int16_t) header.status;
}
goto exit;
} else {
Modified: src/groonga.c (+3 -4)
===================================================================
--- src/groonga.c 2010-07-12 09:45:09 +0000 (5a9dfa9)
+++ src/groonga.c 2010-07-12 10:27:10 +0000 (596386d)
@@ -394,7 +394,7 @@ do_alone(int argc, char **argv)
} while (0)
static int
-recvput(grn_ctx *ctx)
+g_output(grn_ctx *ctx)
{
int flags;
char *str;
@@ -449,7 +449,7 @@ g_client(int argc, char **argv)
grn_ctx_send(ctx, buf, size, 0);
rc = ctx->rc;
if (rc) { break; }
- if (recvput(ctx)) { goto exit; }
+ if (g_output(ctx)) { goto exit; }
if (ctx->stat == GRN_CTX_QUIT) { break; }
}
} else {
@@ -458,7 +458,7 @@ g_client(int argc, char **argv)
grn_obj_unlink(ctx, &text);
} else {
rc = grn_ctx_sendv(ctx, argc, argv, 0);
- if (recvput(ctx)) { goto exit; }
+ if (g_output(ctx)) { goto exit; }
}
} else {
fprintf(stderr, "grn_ctx_connect failed (%s:%d)\n", hostname, port);
@@ -1420,7 +1420,6 @@ output(grn_ctx *ctx, int flags, void *arg)
msg->edge_id = req->edge_id;
msg->header.proto = req->header.proto == GRN_COM_PROTO_MBREQ
? GRN_COM_PROTO_MBRES : req->header.proto;
- ERRCLR(ctx);
if (grn_msg_send(ctx, (grn_obj *)msg,
(flags & GRN_CTX_MORE) ? GRN_CTX_MORE : GRN_CTX_TAIL)) {
edge->stat = EDGE_ABORT;