summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-25 04:38:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-25 04:38:18 +0000
commit320b49473ee64f37787c514e18577106e8231588 (patch)
tree1197f8dd5972bc14d0d42c1d45c479537a7ae688 /io.c
parent5688e811bdbec002c491a96baeec4745235c19ab (diff)
error.c: rb_write_error_str
* error.c (compile_err_append, compile_warn_print, warn_print): use rb_write_error_str() instead of writing to rb_stderr directly. * io.c (rb_write_error_str): a stopgap measure not to unblock GVL. warning from require seems to still have race condition errors. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/io.c b/io.c
index 53539da7b5..b6d5f4a80c 100644
--- a/io.c
+++ b/io.c
@@ -6980,6 +6980,23 @@ rb_write_error(const char *mesg)
rb_write_error2(mesg, strlen(mesg));
}
+void
+rb_write_error_str(VALUE mesg)
+{
+ /* a stopgap measure for the time being */
+ if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0) {
+ size_t len = (size_t)RSTRING_LEN(mesg);
+ if (fwrite(RSTRING_PTR(mesg), sizeof(char), len, stderr) < len) {
+ RB_GC_GUARD(mesg);
+ return;
+ }
+ }
+ else {
+ /* may unlock GVL, and */
+ rb_io_write(rb_stderr, mesg);
+ }
+}
+
static void
must_respond_to(ID mid, VALUE val, ID id)
{