Revision 4cf3fafe src/CloudSupport/mysql_delegate_helper.c

View differences:

src/CloudSupport/mysql_delegate_helper.c
435 435
{
436 436
  struct mysql_cloud_context *ctx;
437 437
  mysql_get_response_t *rsp;
438
  int remaining;
438 439
  int toread;
439 440

  
440 441
  ctx = (struct mysql_cloud_context *) context;
......
442 443
  rsp = (mysql_get_response_t *) req_handler_get_response(ctx->req_handler);
443 444
  if (!rsp) return -1;
444 445

  
445
  if (rsp->read_bytes == rsp->data_length){
446
    free_response(rsp);
447
    req_handler_remove_response(ctx->req_handler);
448
    return 0;
449
  }
450

  
451
  toread = (rsp->data_length <= buffer_size)? rsp->data_length : buffer_size;
446
  remaining = rsp->data_length - rsp->read_bytes;
447
  toread = (remaining <= buffer_size)? remaining : buffer_size;
452 448

  
453 449
  memcpy(buffer_ptr, rsp->current_byte, toread);
454 450
  rsp->current_byte += toread;
455 451
  rsp->read_bytes += toread;
456 452

  
453
  if (rsp->read_bytes == rsp->data_length){
454
    free_response(rsp);
455
    req_handler_remove_response(ctx->req_handler);
456
  }
457

  
457 458
  return toread;
458 459
}
459 460

  

Also available in: Unified diff