Fixed leaks

pull/2135/head
David Garcia Quintas 10 years ago
parent 8a187099ec
commit 4e40336509
  1. 11
      src/core/channel/compress_filter.c
  2. 9
      test/core/end2end/fixtures/chttp2_fullstack_compression.c
  3. 1
      test/core/end2end/tests/invoke_large_request.c

@ -67,7 +67,9 @@ static int compress_send_sb(grpc_compression_algorithm algorithm,
gpr_slice_buffer tmp;
gpr_slice_buffer_init(&tmp);
did_compress = grpc_msg_compress(algorithm, slices, &tmp);
gpr_slice_buffer_swap(slices, &tmp);
if (did_compress) {
gpr_slice_buffer_swap(slices, &tmp);
}
gpr_slice_buffer_destroy(&tmp);
return did_compress;
}
@ -142,8 +144,9 @@ static void process_send_ops(grpc_call_element *elem,
case GRPC_OP_SLICE:
if (skip_compression(channeld, calld)) continue;
GPR_ASSERT(calld->remaining_slice_bytes > 0);
/* add to calld->slices */
gpr_slice_buffer_add(&calld->slices, sop->data.slice);
/* We need to copy the input because gpr_slice_buffer_add takes
* ownership. However, we don't own sop->data.slice, the caller does. */
gpr_slice_buffer_add(&calld->slices, gpr_slice_ref(sop->data.slice));
calld->remaining_slice_bytes -= GPR_SLICE_LENGTH(sop->data.slice);
if (calld->remaining_slice_bytes == 0) {
/* compress */
@ -186,6 +189,8 @@ static void process_send_ops(grpc_call_element *elem,
case GRPC_OP_SLICE:
if (did_compress) {
if (j < calld->slices.count) {
/* swap the input slices for their compressed counterparts */
gpr_slice_unref(sop->data.slice);
sop->data.slice = gpr_slice_ref(calld->slices.slices[j++]);
}
}

@ -64,10 +64,11 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression(
int port = grpc_pick_unused_port_or_die();
fullstack_compression_fixture_data *ffd =
gpr_malloc(sizeof(fullstack_compression_fixture_data));
memset(&f, 0, sizeof(f));
memset(ffd, 0, sizeof(fullstack_compression_fixture_data));
gpr_join_host_port(&ffd->localaddr, "localhost", port);
memset(&f, 0, sizeof(f));
f.fixture_data = ffd;
f.cq = grpc_completion_queue_create();
@ -77,6 +78,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression(
void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args) {
fullstack_compression_fixture_data *ffd = f->fixture_data;
if (ffd->client_args_compression != NULL) {
grpc_channel_args_destroy(ffd->client_args_compression);
}
ffd->client_args_compression = grpc_channel_args_set_compression_level(
client_args, GRPC_COMPRESS_LEVEL_HIGH);
f->client = grpc_channel_create(ffd->localaddr, ffd->client_args_compression);
@ -85,6 +89,9 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture *f,
void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture *f,
grpc_channel_args *server_args) {
fullstack_compression_fixture_data *ffd = f->fixture_data;
if (ffd->server_args_compression != NULL) {
grpc_channel_args_destroy(ffd->server_args_compression);
}
ffd->server_args_compression = grpc_channel_args_set_compression_level(
server_args, GRPC_COMPRESS_LEVEL_HIGH);
if (f->server) {

@ -228,6 +228,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
grpc_byte_buffer_destroy(response_payload);
grpc_byte_buffer_destroy(request_payload_recv);
grpc_byte_buffer_destroy(response_payload_recv);
gpr_slice_unref(request_payload_slice);
gpr_slice_unref(response_payload_slice);
end_test(&f);

Loading…
Cancel
Save