Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/ruby/ext/grpc/rb_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,12 @@ const rb_data_type_t grpc_rb_md_ary_data_type = {
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
/* it is unsafe to specify RUBY_TYPED_FREE_IMMEDIATELY because
* grpc_rb_call_destroy
* touches a hash object.
* TODO(yugui) Directly use st_table and call the free function earlier?
*/
0,
#endif
};

/* Describes grpc_call struct for RTypedData */
Expand All @@ -129,9 +127,7 @@ static const rb_data_type_t grpc_call_data_type = {"grpc_call",
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
};

/* Error code details is a hash containing text strings describing errors */
Expand Down
13 changes: 7 additions & 6 deletions src/ruby/ext/grpc/rb_call_credentials.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ static VALUE grpc_rb_cCallCredentials = Qnil;
* object that is used to hold references to any objects used to create the
* credentials. */
typedef struct grpc_rb_call_credentials {
/* Holder of ruby objects involved in contructing the credentials */
/* Holder of ruby objects involved in contructing the credentials.
Must be written using RB_OBJ_WRITE for proper write barriers */
VALUE mark;

/* The actual credentials */
Expand Down Expand Up @@ -171,6 +172,8 @@ static int grpc_rb_call_credentials_plugin_get_metadata(
size_t* num_creds_md, grpc_status_code* status,
const char** error_details) {
callback_params* params = gpr_zalloc(sizeof(callback_params));
// FIXME: do we need to call a gc function for this VALUE? This
// callback_params doesn't have a corresponding rb_data_type_t.
params->get_metadata = (VALUE)state;
grpc_auth_metadata_context_copy(&context, &params->context);
params->user_data = user_data;
Expand Down Expand Up @@ -222,9 +225,7 @@ static rb_data_type_t grpc_rb_call_credentials_data_type = {
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};

/* Allocates CallCredentials instances.
Expand All @@ -251,7 +252,7 @@ VALUE grpc_rb_wrap_call_credentials(grpc_call_credentials* c, VALUE mark) {
TypedData_Get_Struct(rb_wrapper, grpc_rb_call_credentials,
&grpc_rb_call_credentials_data_type, wrapper);
wrapper->wrapped = c;
wrapper->mark = mark;
RB_OBJ_WRITE(rb_wrapper, &wrapper->mark, mark);
return rb_wrapper;
}

Expand Down Expand Up @@ -289,7 +290,7 @@ static VALUE grpc_rb_call_credentials_init(VALUE self, VALUE proc) {
return Qnil;
}

wrapper->mark = proc;
RB_OBJ_WRITE(self, &wrapper->mark, proc);
wrapper->wrapped = creds;
rb_ivar_set(self, id_callback, proc);

Expand Down
7 changes: 3 additions & 4 deletions src/ruby/ext/grpc/rb_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ typedef struct bg_watched_channel {

/* grpc_rb_channel wraps a grpc_channel. */
typedef struct grpc_rb_channel {
/* Ruby VALUE that must be written using RB_OBJ_WRITE for proper write barriers */
VALUE credentials;
grpc_channel_args args;
/* The actual channel (protected in a wrapper to tell when it's safe to
Expand Down Expand Up @@ -188,9 +189,7 @@ static rb_data_type_t grpc_channel_data_type = {"grpc_channel",
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};

/* Allocates grpc_rb_channel instances. */
Expand Down Expand Up @@ -239,7 +238,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
ch = grpc_channel_create(target_chars, insecure_creds, &wrapper->args);
grpc_channel_credentials_release(insecure_creds);
} else {
wrapper->credentials = credentials;
RB_OBJ_WRITE(self, &wrapper->credentials, credentials);
if (grpc_rb_is_channel_credentials(credentials)) {
creds = grpc_rb_get_wrapped_channel_credentials(credentials);
} else if (grpc_rb_is_xds_channel_credentials(credentials)) {
Expand Down
2 changes: 0 additions & 2 deletions src/ruby/ext/grpc/rb_channel_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ static rb_data_type_t grpc_rb_channel_args_data_type = {
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
};

/* A callback the processes the hash key values in channel_args hash */
Expand Down
9 changes: 4 additions & 5 deletions src/ruby/ext/grpc/rb_channel_credentials.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ static char* pem_root_certs = NULL;
* mark object that is used to hold references to any objects used to create
* the credentials. */
typedef struct grpc_rb_channel_credentials {
/* Holder of ruby objects involved in constructing the credentials */
/* Holder of ruby objects involved in constructing the credentials.
Must be written using RB_OBJ_WRITE for proper write barriers */
VALUE mark;

/* The actual credentials */
Expand Down Expand Up @@ -86,9 +87,7 @@ static rb_data_type_t grpc_rb_channel_credentials_data_type = {
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};

/* Allocates ChannelCredential instances.
Expand Down Expand Up @@ -116,7 +115,7 @@ VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials* c,
TypedData_Get_Struct(rb_wrapper, grpc_rb_channel_credentials,
&grpc_rb_channel_credentials_data_type, wrapper);
wrapper->wrapped = c;
wrapper->mark = mark;
RB_OBJ_WRITE(rb_wrapper, &wrapper->mark, mark);
return rb_wrapper;
}

Expand Down
2 changes: 0 additions & 2 deletions src/ruby/ext/grpc/rb_compression_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ static rb_data_type_t grpc_rb_compression_options_data_type = {
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
};

/* Allocates CompressionOptions instances.
Expand Down
2 changes: 0 additions & 2 deletions src/ruby/ext/grpc/rb_grpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ static rb_data_type_t grpc_rb_timespec_data_type = {
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
};

/* Alloc func that blocks allocation of a given object by raising an
Expand Down
2 changes: 0 additions & 2 deletions src/ruby/ext/grpc/rb_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,11 @@ static const rb_data_type_t grpc_rb_server_data_type = {
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
/* It is unsafe to specify RUBY_TYPED_FREE_IMMEDIATELY because the free
* function would block and we might want to unlock GVL
* TODO(yugui) Unlock GVL?
*/
0,
#endif
};

/* Allocates grpc_rb_server instances. */
Expand Down
2 changes: 0 additions & 2 deletions src/ruby/ext/grpc/rb_server_credentials.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ static const rb_data_type_t grpc_rb_server_credentials_data_type = {
{NULL, NULL}},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
};

/* Allocates ServerCredential instances.
Expand Down
9 changes: 4 additions & 5 deletions src/ruby/ext/grpc/rb_xds_channel_credentials.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ static VALUE grpc_rb_cXdsChannelCredentials = Qnil;
* provides a mark object that is used to hold references to any objects used to
* create the credentials. */
typedef struct grpc_rb_xds_channel_credentials {
/* Holder of ruby objects involved in constructing the credentials */
/* Holder of ruby objects involved in constructing the credentials.
Must be written using RB_OBJ_WRITE for proper write barriers */
VALUE mark;

/* The actual credentials */
Expand Down Expand Up @@ -83,9 +84,7 @@ static rb_data_type_t grpc_rb_xds_channel_credentials_data_type = {
GRPC_RB_MEMSIZE_UNAVAILABLE, NULL},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};

/* Allocates ChannelCredential instances.
Expand Down Expand Up @@ -114,7 +113,7 @@ VALUE grpc_rb_xds_wrap_channel_credentials(grpc_channel_credentials* c,
TypedData_Get_Struct(rb_wrapper, grpc_rb_xds_channel_credentials,
&grpc_rb_xds_channel_credentials_data_type, wrapper);
wrapper->wrapped = c;
wrapper->mark = mark;
RB_OBJ_WRITE(rb_wrapper, &wrapper->mark, mark);
return rb_wrapper;
}

Expand Down
2 changes: 0 additions & 2 deletions src/ruby/ext/grpc/rb_xds_server_credentials.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ static const rb_data_type_t grpc_rb_xds_server_credentials_data_type = {
GRPC_RB_MEMSIZE_UNAVAILABLE, NULL},
NULL,
NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
};

/* Allocates ServerCredential instances.
Expand Down
Loading