Skip to content

Commit

Permalink
Flush buffer before execute command.
Browse files Browse the repository at this point in the history
  • Loading branch information
miyanaga committed Apr 14, 2012
1 parent af1568a commit c1191a9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Console.xs
Expand Up @@ -135,6 +135,12 @@ void Groonga::console( strings &input, strings &output ) {
string &line = *it; string &line = *it;
if ( line.length() < 1 ) continue; if ( line.length() < 1 ) continue;


// Flush buffer.
char *res;
unsigned int len;
int flags;
grn_ctx_recv( &context, &res, &len, &flags );

rc = grn_ctx_send( &context, line.c_str(), line.length(), context_flags ); rc = grn_ctx_send( &context, line.c_str(), line.length(), context_flags );


// Handle errors. // Handle errors.
Expand All @@ -149,9 +155,6 @@ void Groonga::console( strings &input, strings &output ) {
} }


// Try to receive result. // Try to receive result.
char *res;
unsigned int len;
int flags;
grn_ctx_recv( &context, &res, &len, &flags ); grn_ctx_recv( &context, &res, &len, &flags );
if ( context.rc == GRN_SUCCESS && len > 0 ) { if ( context.rc == GRN_SUCCESS && len > 0 ) {
output.push_back(string(res, len)); output.push_back(string(res, len));
Expand Down

0 comments on commit c1191a9

Please sign in to comment.