summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-23 08:17:17 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-23 08:17:17 +0000
commit4ccd99734480f7ac4524e6c1e6fe51839dbb4c76 (patch)
tree9269306b6508b72e371146550a82350a74815bd5
parent9a207a840db34f04d7b08603f0debb251eb48893 (diff)
downloadruby-4ccd99734480f7ac4524e6c1e6fe51839dbb4c76.tar.gz
ruby-4ccd99734480f7ac4524e6c1e6fe51839dbb4c76.tar.xz
ruby-4ccd99734480f7ac4524e6c1e6fe51839dbb4c76.zip
* thread.c, include/ruby/intern.h (rb_thread_interrupted): added.
* io.c: use VALUE of thead instead of rb_tread_t to check interrupts. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--include/ruby/intern.h1
-rw-r--r--io.c9
-rw-r--r--thread.c9
4 files changed, 20 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index e41ed575b..6d1dfbf3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Sep 23 17:14:31 2008 Koichi Sasada <ko1@atdot.net>
+
+ * thread.c, include/ruby/intern.h (rb_thread_interrupted): added.
+
+ * io.c: use VALUE of thead instead of rb_tread_t to check interrupts.
+
Tue Sep 23 17:05:14 2008 Koichi Sasada <ko1@atdot.net>
* class.c, vm_core.h: move decl of rb_iseq_clone() to class.c.
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 105ca62bd..5f6882d56 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -659,6 +659,7 @@ VALUE rb_struct_define_without_accessor(const char *, VALUE, rb_alloc_func_t, ..
typedef void rb_unblock_function_t(void *);
typedef VALUE rb_blocking_function_t(void *);
void rb_thread_check_ints(void);
+int rb_thread_interrupted(VALUE thval);
VALUE rb_thread_blocking_region(rb_blocking_function_t *func, void *data1,
rb_unblock_function_t *ubf, void *data2);
#define RUBY_UBF_IO ((rb_unblock_function_t *)-1)
diff --git a/io.c b/io.c
index 2ea192cf4..e45766878 100644
--- a/io.c
+++ b/io.c
@@ -13,7 +13,6 @@
#include "ruby/ruby.h"
#include "ruby/io.h"
-#include "vm_core.h"
#include <ctype.h>
#include <errno.h>
@@ -6979,7 +6978,7 @@ struct copy_stream_struct {
int error_no;
const char *notimp;
rb_fdset_t fds;
- rb_thread_t *th;
+ VALUE th;
};
static int
@@ -7107,7 +7106,7 @@ copy_stream_sendfile(struct copy_stream_struct *stp)
#endif
if (copy_stream_wait_write(stp) == -1)
return -1;
- if (RUBY_VM_INTERRUPTED(stp->th))
+ if (rb_thread_interrupted(stp->th))
return -1;
goto retry_sendfile;
}
@@ -7237,7 +7236,7 @@ copy_stream_read_write(struct copy_stream_struct *stp)
if (!use_eof)
copy_length -= ss;
- if (RUBY_VM_INTERRUPTED(stp->th))
+ if (rb_thread_interrupted(stp->th))
return;
}
}
@@ -7340,7 +7339,7 @@ copy_stream_body(VALUE arg)
rb_io_t *src_fptr = 0, *dst_fptr = 0;
int src_fd, dst_fd;
- stp->th = GET_THREAD();
+ stp->th = rb_thread_current();
stp->total = 0;
diff --git a/thread.c b/thread.c
index 9b0a91ee7..7416fabb2 100644
--- a/thread.c
+++ b/thread.c
@@ -899,6 +899,15 @@ rb_thread_check_trap_pending(void)
return GET_THREAD()->exec_signal != 0;
}
+/* This function can be called in blocking region. */
+int
+rb_thread_interrupted(VALUE thval)
+{
+ rb_thread_t *th;
+ GetThreadPtr(thval, th);
+ return RUBY_VM_INTERRUPTED(th);
+}
+
struct timeval rb_time_timeval();
void