Project

General

Profile

Bug #14204 ยป 0001-socket-use-frozen-string-buffer-when-releasing-GVL.patch

normalperson (Eric Wong), 12/19/2017 07:49 AM

View differences:

ext/socket/ancdata.c
1137 1137
    rb_io_t *fptr;
1138 1138
    struct msghdr mh;
1139 1139
    struct iovec iov;
1140
    VALUE tmp;
1140 1141
    int controls_num;
1141 1142
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
1142 1143
    VALUE controls_str = 0;
......
1151 1152
#endif
1152 1153

  
1153 1154
    StringValue(data);
1155
    tmp = rb_str_tmp_frozen_acquire(data);
1154 1156

  
1155 1157
    if (!RB_TYPE_P(controls, T_ARRAY)) {
1156 1158
	controls = rb_ary_new();
......
1261 1263
    }
1262 1264
    mh.msg_iovlen = 1;
1263 1265
    mh.msg_iov = &iov;
1264
    iov.iov_base = RSTRING_PTR(data);
1265
    iov.iov_len = RSTRING_LEN(data);
1266
    iov.iov_base = RSTRING_PTR(tmp);
1267
    iov.iov_len = RSTRING_LEN(tmp);
1266 1268
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
1267 1269
    if (controls_str) {
1268 1270
        mh.msg_control = RSTRING_PTR(controls_str);
......
1295 1297
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
1296 1298
    RB_GC_GUARD(controls_str);
1297 1299
#endif
1300
    rb_str_tmp_frozen_release(data, tmp);
1298 1301

  
1299 1302
    return SSIZET2NUM(ss);
1300 1303
}
internal.h
1704 1704
char *rb_str_fill_terminator(VALUE str, const int termlen);
1705 1705
void rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen);
1706 1706
VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
1707
VALUE rb_str_tmp_frozen_acquire(VALUE str);
1708
void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
1709 1707
VALUE rb_str_chomp_string(VALUE str, VALUE chomp);
1710 1708
#ifdef RUBY_ENCODING_H
1711 1709
VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
......
1956 1954
#endif
1957 1955

  
1958 1956
/* string.c (export) */
1957
VALUE rb_str_tmp_frozen_acquire(VALUE str);
1958
void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
1959 1959
#ifdef RUBY_ENCODING_H
1960 1960
/* internal use */
1961 1961
VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
1962
-