Skip to content
Browse files

* process.c (rb_waitpid_blocking, rb_waitpid): use UBF feature.

* thread_win32.ci (rb_w32_wait_events_blocking): blocking version.

* win32/win32.c (waitpid): use rb_w32_wait_events_blocking().




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent f425798 commit c034fce5cef74af6d1178eba4bec536e1fa70728 @nobu nobu committed
Showing with 52 additions and 19 deletions.
  1. +8 −1 ChangeLog
  2. +35 −15 process.c
  3. +7 −1 thread_win32.ci
  4. +2 −2 win32/win32.c
View
9 ChangeLog
@@ -1,7 +1,9 @@
-Sat Feb 24 18:41:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Feb 24 18:43:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* intern.h (rb_thread_blocking_region): add prototype.
+ * process.c (rb_waitpid_blocking, rb_waitpid): use UBF feature.
+
* thread.c (rb_thread_debug): added runtime debugging flag.
* thread.c (BLOCKING_REGION): restore previous UBF.
@@ -12,6 +14,11 @@ Sat Feb 24 18:41:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ ubf_handle() on Win32
+ none on cygwin
+ * thread_win32.ci (rb_w32_wait_events_blocking): blocking version.
+
+ * win32/win32.c (waitpid): use rb_w32_wait_events_blocking().
+
+
Sat Feb 24 17:45:48 2007 Minero Aoki <aamine@loveruby.net>
* parse.y (f_arg, opt_f_block_arg): ripper should export VALUE.
View
50 process.c
@@ -567,37 +567,58 @@ pst_wcoredump(VALUE st)
#if !defined(HAVE_WAITPID) && !defined(HAVE_WAIT4)
#define NO_WAITPID
static st_table *pid_tbl;
+#else
+struct waitpid_arg {
+ rb_pid_t pid;
+ int *st;
+ int flags;
+};
#endif
-rb_pid_t
-rb_waitpid(rb_pid_t pid, int *st, int flags)
+static VALUE
+rb_waitpid_blocking(rb_thread_t *th, void *data)
{
rb_pid_t result;
#ifndef NO_WAITPID
- int oflags = flags;
- if (!rb_thread_alone()) { /* there're other threads to run */
- flags |= WNOHANG;
- }
+ struct waitpid_arg *arg = data;
+#endif
- retry:
TRAP_BEG;
-#ifdef HAVE_WAITPID
- result = waitpid(pid, st, flags);
+#if defined NO_WAITPID
+ result = wait(data);
+#elif defined HAVE_WAITPID
+ result = waitpid(arg->pid, arg->st, arg->flags);
#else /* HAVE_WAIT4 */
- result = wait4(pid, st, flags, NULL);
+ result = wait4(arg->pid, arg->st, arg->flags, NULL);
#endif
TRAP_END;
+ return (VALUE)result;
+}
+
+rb_pid_t
+rb_waitpid(rb_pid_t pid, int *st, int flags)
+{
+ rb_pid_t result;
+#ifndef NO_WAITPID
+ struct waitpid_arg arg;
+
+ arg.pid = pid;
+ arg.st = st;
+ arg.flags = flags;
+ retry:
+ result = (rb_pid_t)rb_thread_blocking_region(rb_waitpid_blocking,
+ &arg, RB_UBF_DFL);
if (result < 0) {
+#if 0
if (errno == EINTR) {
rb_thread_polling();
goto retry;
}
+#endif
return -1;
}
if (result == 0) {
- if (oflags & WNOHANG) return 0;
rb_thread_polling();
- if (rb_thread_alone()) flags = oflags;
goto retry;
}
#else /* NO_WAITPID */
@@ -612,9 +633,8 @@ rb_waitpid(rb_pid_t pid, int *st, int flags)
}
for (;;) {
- TRAP_BEG;
- result = wait(st);
- TRAP_END;
+ result = (rb_pid_t)rb_thread_blocking_region(rb_waitpid_blocking,
+ st, RB_UBF_DFL);
if (result < 0) {
if (errno == EINTR) {
rb_thread_schedule();
View
8 thread_win32.ci
@@ -110,11 +110,17 @@ static void ubf_handle(rb_thread_t *th);
#define ubf_select ubf_handle
int
+rb_w32_wait_events_blocking(HANDLE *events, int num, DWORD timeout)
+{
+ return w32_wait_events(events, num, timeout, GET_THREAD());
+}
+
+int
rb_w32_wait_events(HANDLE *events, int num, DWORD timeout)
{
int ret;
- BLOCKING_REGION(ret = w32_wait_events(events, num, timeout, GET_THREAD()), ubf_handle);
+ BLOCKING_REGION(ret = rb_w32_wait_events_blocking(events, num, timeout), ubf_handle);
return ret;
}
View
4 win32/win32.c
@@ -2936,7 +2936,7 @@ waitpid(rb_pid_t pid, int *stat_loc, int options)
return -1;
}
- ret = rb_w32_wait_events(events, count, timeout);
+ ret = rb_w32_wait_events_blocking(events, count, timeout);
if (ret == WAIT_TIMEOUT) return 0;
if ((ret -= WAIT_OBJECT_0) == count) {
return -1;
@@ -2957,7 +2957,7 @@ waitpid(rb_pid_t pid, int *stat_loc, int options)
while (!(pid = poll_child_status(child, stat_loc))) {
/* wait... */
- if (rb_w32_wait_events(&child->hProcess, 1, timeout) != WAIT_OBJECT_0) {
+ if (rb_w32_wait_events_blocking(&child->hProcess, 1, timeout) != WAIT_OBJECT_0) {
/* still active */
pid = 0;
break;

0 comments on commit c034fce

Please sign in to comment.
Something went wrong with that request. Please try again.