socket: use frozen string buffer when releasing GVL
Thanks for the patch by normalperson (Eric Wong) [Bug #14204].
This commit is contained in:
parent
5bd83909b9
commit
4900a10689
@ -1137,6 +1137,7 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags,
|
|||||||
rb_io_t *fptr;
|
rb_io_t *fptr;
|
||||||
struct msghdr mh;
|
struct msghdr mh;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
|
VALUE tmp;
|
||||||
int controls_num;
|
int controls_num;
|
||||||
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
VALUE controls_str = 0;
|
VALUE controls_str = 0;
|
||||||
@ -1151,6 +1152,7 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
StringValue(data);
|
StringValue(data);
|
||||||
|
tmp = rb_str_tmp_frozen_acquire(data);
|
||||||
|
|
||||||
if (!RB_TYPE_P(controls, T_ARRAY)) {
|
if (!RB_TYPE_P(controls, T_ARRAY)) {
|
||||||
controls = rb_ary_new();
|
controls = rb_ary_new();
|
||||||
@ -1261,8 +1263,8 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags,
|
|||||||
}
|
}
|
||||||
mh.msg_iovlen = 1;
|
mh.msg_iovlen = 1;
|
||||||
mh.msg_iov = &iov;
|
mh.msg_iov = &iov;
|
||||||
iov.iov_base = RSTRING_PTR(data);
|
iov.iov_base = RSTRING_PTR(tmp);
|
||||||
iov.iov_len = RSTRING_LEN(data);
|
iov.iov_len = RSTRING_LEN(tmp);
|
||||||
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
if (controls_str) {
|
if (controls_str) {
|
||||||
mh.msg_control = RSTRING_PTR(controls_str);
|
mh.msg_control = RSTRING_PTR(controls_str);
|
||||||
@ -1295,6 +1297,7 @@ bsock_sendmsg_internal(VALUE sock, VALUE data, VALUE vflags,
|
|||||||
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
RB_GC_GUARD(controls_str);
|
RB_GC_GUARD(controls_str);
|
||||||
#endif
|
#endif
|
||||||
|
rb_str_tmp_frozen_release(data, tmp);
|
||||||
|
|
||||||
return SSIZET2NUM(ss);
|
return SSIZET2NUM(ss);
|
||||||
}
|
}
|
||||||
|
@ -2080,8 +2080,6 @@ VALUE rb_id_quote_unprintable(ID);
|
|||||||
char *rb_str_fill_terminator(VALUE str, const int termlen);
|
char *rb_str_fill_terminator(VALUE str, const int termlen);
|
||||||
void rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen);
|
void rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen);
|
||||||
VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
|
VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
|
||||||
VALUE rb_str_tmp_frozen_acquire(VALUE str);
|
|
||||||
void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
|
|
||||||
VALUE rb_str_chomp_string(VALUE str, VALUE chomp);
|
VALUE rb_str_chomp_string(VALUE str, VALUE chomp);
|
||||||
#ifdef RUBY_ENCODING_H
|
#ifdef RUBY_ENCODING_H
|
||||||
VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
|
VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
|
||||||
@ -2376,6 +2374,8 @@ VALUE rb_gcd_gmp(VALUE x, VALUE y);
|
|||||||
int rb_grantpt(int fd);
|
int rb_grantpt(int fd);
|
||||||
|
|
||||||
/* string.c (export) */
|
/* string.c (export) */
|
||||||
|
VALUE rb_str_tmp_frozen_acquire(VALUE str);
|
||||||
|
void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
|
||||||
#ifdef RUBY_ENCODING_H
|
#ifdef RUBY_ENCODING_H
|
||||||
/* internal use */
|
/* internal use */
|
||||||
VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
|
VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user