Revision 4cf3fafe

View differences:

src/CloudSupport/libs3_delegate_helper.c
632 632
{
633 633
  struct libs3_cloud_context *ctx;
634 634
  libs3_get_response_t *rsp;
635
  int remaining;
635 636
  int toread;
636 637

  
637 638
  ctx = (struct libs3_cloud_context *) context;
......
639 640
  rsp = (libs3_get_response_t *) req_handler_get_response(ctx->req_handler);
640 641
  if (!rsp) return -1;
641 642

  
642
  if (rsp->read_bytes == rsp->data_length){
643
    req_handler_remove_response(ctx->req_handler);
644
    return 0;
645
  }
646

  
647
  toread = (rsp->data_length <= buffer_size)? rsp->data_length : buffer_size;
643
  remaining = rsp->data_length - rsp->read_bytes;
644
  toread = (remaining <= buffer_size)? remaining : buffer_size;
648 645

  
649 646
  memcpy(buffer_ptr, rsp->current_byte, toread);
650 647
  rsp->current_byte += toread;
651 648
  rsp->read_bytes += toread;
652 649

  
650
  if (rsp->read_bytes == rsp->data_length){
651
    req_handler_remove_response(ctx->req_handler);
652
  }
653

  
653 654
  return toread;
654 655
}
655 656

  
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