summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-15 13:34:32 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-15 13:34:32 +0000
commit2fbd11c77a0013f56b8b58183298da652f9d6ee6 (patch)
treea26d04857e4a44a663a8335b2847f38cb1397cff
parent56b83d06e849167f40898ffacf27e15aa50bd96f (diff)
Update to ruby/spec@c730f07
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--spec/rubyspec/optional/capi/ext/thread_spec.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/spec/rubyspec/optional/capi/ext/thread_spec.c b/spec/rubyspec/optional/capi/ext/thread_spec.c
index d2e937f..3bfe76b 100644
--- a/spec/rubyspec/optional/capi/ext/thread_spec.c
+++ b/spec/rubyspec/optional/capi/ext/thread_spec.c
@@ -28,23 +28,27 @@ static VALUE thread_spec_rb_thread_alone() {
static void* blocking_gvl_func(void* data) {
int rfd = *(int *)data;
char dummy;
- ssize_t rv;
+ ssize_t r;
do {
- rv = read(rfd, &dummy, 1);
- } while (rv == -1 && errno == EINTR);
+ r = read(rfd, &dummy, 1);
+ } while (r == -1 && errno == EINTR);
- return (void*)((rv == 1) ? Qtrue : Qfalse);
+ close(rfd);
+
+ return (void*)((r == 1) ? Qtrue : Qfalse);
}
static void unblock_gvl_func(void *data) {
int wfd = *(int *)data;
- char dummy = 0;
- ssize_t rv;
+ char dummy = 'A';
+ ssize_t r;
do {
- rv = write(wfd, &dummy, 1);
- } while (rv == -1 && errno == EINTR);
+ r = write(wfd, &dummy, 1);
+ } while (r == -1 && errno == EINTR);
+
+ close(wfd);
}
/* Returns true if the thread is interrupted. */
@@ -57,8 +61,6 @@ static VALUE thread_spec_rb_thread_call_without_gvl(VALUE self) {
}
ret = rb_thread_call_without_gvl(blocking_gvl_func, &fds[0],
unblock_gvl_func, &fds[1]);
- close(fds[0]);
- close(fds[1]);
return (VALUE)ret;
}