summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-26 11:54:05 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-26 11:54:05 +0000
commitdd459e887500884c4dd3683795f1cc3bf7d69031 (patch)
treeee8c28104ca36462148f2b245591bfd214e1a0e0
parente1a304ff665f74036c7a848cb1fd3cf49e3ae3db (diff)
merge revision(s) 22299:
* eval.c (rb_thread_schedule): handle EBADF of select as well. [ruby-core:21264] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@23577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--eval.c83
-rw-r--r--version.h10
3 files changed, 78 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index f72cf3c856..68e8f7fd23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue May 26 20:50:32 2009 Tanaka Akira <akr@fsij.org>
+
+ * eval.c (rb_thread_schedule): handle EBADF of select as well.
+ [ruby-core:21264]
+
Wed Apr 8 18:59:52 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (subtruct): check tv_sec.
diff --git a/eval.c b/eval.c
index b705302d71..d53101ca6e 100644
--- a/eval.c
+++ b/eval.c
@@ -74,7 +74,16 @@ char *strrchr _((const char*,const char));
#include <time.h>
-#ifdef __BEOS__
+#if defined(HAVE_FCNTL_H) || defined(_WIN32)
+#include <fcntl.h>
+#elif defined(HAVE_SYS_FCNTL_H)
+#include <sys/fcntl.h>
+#endif
+#ifdef __CYGWIN__
+#include <io.h>
+#endif
+
+#if defined(__BEOS__) && !defined(BONE)
#include <net/socket.h>
#endif
@@ -11084,20 +11093,60 @@ rb_thread_schedule()
#ifdef ERESTART
if (e == ERESTART) goto again;
#endif
- FOREACH_THREAD_FROM(curr, th) {
- if (th->wait_for & WAIT_SELECT) {
- int v = 0;
-
- v |= find_bad_fds(&readfds, &th->readfds, th->fd);
- v |= find_bad_fds(&writefds, &th->writefds, th->fd);
- v |= find_bad_fds(&exceptfds, &th->exceptfds, th->fd);
- if (v) {
- th->select_value = n;
- n = max;
- }
- }
- }
- END_FOREACH_FROM(curr, th);
+ if (e == EBADF) {
+ int badfd = -1;
+ int fd;
+ int dummy;
+ for (fd = 0; fd <= max; fd++) {
+ if ((FD_ISSET(fd, &readfds) ||
+ FD_ISSET(fd, &writefds) ||
+ FD_ISSET(fd, &exceptfds)) &&
+ fcntl(fd, F_GETFD, &dummy) == -1 &&
+ errno == EBADF) {
+ badfd = fd;
+ break;
+ }
+ }
+ if (badfd != -1) {
+ FOREACH_THREAD_FROM(curr, th) {
+ if (th->wait_for & WAIT_FD) {
+ if (th->fd == badfd) {
+ found = 1;
+ th->status = THREAD_RUNNABLE;
+ th->fd = 0;
+ break;
+ }
+ }
+ if (th->wait_for & WAIT_SELECT) {
+ if (FD_ISSET(badfd, &th->readfds) ||
+ FD_ISSET(badfd, &th->writefds) ||
+ FD_ISSET(badfd, &th->exceptfds)) {
+ found = 1;
+ th->status = THREAD_RUNNABLE;
+ th->select_value = -EBADF;
+ break;
+ }
+ }
+ }
+ END_FOREACH_FROM(curr, th);
+ }
+ }
+ else {
+ FOREACH_THREAD_FROM(curr, th) {
+ if (th->wait_for & WAIT_SELECT) {
+ int v = 0;
+
+ v |= find_bad_fds(&readfds, &th->readfds, th->fd);
+ v |= find_bad_fds(&writefds, &th->writefds, th->fd);
+ v |= find_bad_fds(&exceptfds, &th->exceptfds, th->fd);
+ if (v) {
+ th->select_value = n;
+ n = max;
+ }
+ }
+ }
+ END_FOREACH_FROM(curr, th);
+ }
}
if (select_timeout && n == 0) {
if (now < 0.0) now = timeofday();
@@ -11408,6 +11457,10 @@ rb_thread_select(max, read, write, except, timeout)
if (read) *read = curr_thread->readfds;
if (write) *write = curr_thread->writefds;
if (except) *except = curr_thread->exceptfds;
+ if (curr_thread->select_value < 0) {
+ errno = -curr_thread->select_value;
+ return -1;
+ }
return curr_thread->select_value;
}
diff --git a/version.h b/version.h
index 4aca9b35f7..ca3addcb7f 100644
--- a/version.h
+++ b/version.h
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2009-04-08"
+#define RUBY_RELEASE_DATE "2009-05-26"
#define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20090408
-#define RUBY_PATCHLEVEL 160
+#define RUBY_RELEASE_CODE 20090526
+#define RUBY_PATCHLEVEL 161
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_YEAR 2009
-#define RUBY_RELEASE_MONTH 4
-#define RUBY_RELEASE_DAY 8
+#define RUBY_RELEASE_MONTH 5
+#define RUBY_RELEASE_DAY 26
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];