Skip to content

Commit

Permalink
fixed a bug in ngx_http_drizzle_output_field.
Browse files Browse the repository at this point in the history
  • Loading branch information
agentzh committed Jan 6, 2010
1 parent 1fb3f1f commit 3197c6e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/ngx_http_drizzle_output.c
Expand Up @@ -387,7 +387,7 @@ ngx_http_drizzle_output_field(ngx_http_request_t *r, size_t offset,
size_t len, size_t total, drizzle_field_t field)
{
ngx_http_upstream_t *u = r->upstream;
size_t size;
size_t size = 0;
ngx_buf_t *b;
ngx_chain_t *cl;
ngx_int_t rc;
Expand Down Expand Up @@ -438,6 +438,9 @@ ngx_http_drizzle_output_field(ngx_http_request_t *r, size_t offset,
}

if (b->last != b->end) {
dd("offset %d, len %d, size %d", (int) offset,
(int) len, (int) size);

ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"diizzle: FATAL: output field buffer error");

Expand Down
15 changes: 11 additions & 4 deletions src/ngx_http_drizzle_processor.c
Expand Up @@ -38,13 +38,13 @@ ngx_http_drizzle_process_events(ngx_http_request_t *r)
drizzle_con_st *dc;
ngx_int_t rc;

dd("drizzle process events");

u = r->upstream;
c = u->peer.connection;

dp = u->peer.data;

dd("drizzle process events, state: %d", dp->state);

if ( ! ngx_http_upstream_drizzle_is_my_peer(&u->peer)) {
ngx_log_error(NGX_LOG_ERR, c->log, 0,
"drizzle: process events: it seems you "
Expand All @@ -64,8 +64,12 @@ ngx_http_drizzle_process_events(ngx_http_request_t *r)
* by the nginx core can play well enough with poll().
* */

dd("before con wait");

drizzle_con_wait(dc->drizzle);

dd("after con wait");

switch (dp->state) {
case state_db_connect:
rc = ngx_http_upstream_drizzle_connect(r, c, dp, dc);
Expand All @@ -92,6 +96,8 @@ ngx_http_drizzle_process_events(ngx_http_request_t *r)
return NGX_ERROR;
}

dd("rc == %d", rc);

if (rc == NGX_ERROR) {
ngx_http_upstream_drizzle_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);

Expand Down Expand Up @@ -301,6 +307,7 @@ ngx_http_upstream_drizzle_recv_rows(ngx_http_request_t *r,
dd("drizzle recv rows");

for (;;) {
dd("row: %d", (int) dp->drizzle_row);
if (dp->drizzle_row == 0) {
dp->drizzle_row = drizzle_row_read(&dp->drizzle_res, &ret);

Expand Down Expand Up @@ -349,8 +356,8 @@ ngx_http_upstream_drizzle_recv_rows(ngx_http_request_t *r,
/* dp->drizzle_row != 0 */

for (;;) {
/* here we rely on libdrizzle to buffer each field
* for us */
dd("field: ");

field = drizzle_field_read(&dp->drizzle_res, &offset, &len,
&total, &ret);

Expand Down
1 change: 1 addition & 0 deletions test/t/sanity.t
Expand Up @@ -69,6 +69,7 @@ Content-Type: application/x-resty-dbd-stream
"\x{03}\x{00}\x{00}\x{00}". # field len
"bob". # field data
"\x{00}" # row list terminator
--- timeout: 15
Expand Down

0 comments on commit 3197c6e

Please sign in to comment.