summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog36
-rw-r--r--configure.in8
-rw-r--r--file.c4
-rw-r--r--include/ruby/intern.h5
-rw-r--r--include/ruby/missing.h17
-rw-r--r--io.c5
-rw-r--r--random.c3
-rw-r--r--test/ruby/test_io.rb26
-rw-r--r--thread.c13
-rw-r--r--thread_pthread.c3
-rw-r--r--time.c4
-rw-r--r--version.h2
-rw-r--r--win32/Makefile.sub2
13 files changed, 120 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a90b43ad6..ce748258d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * include/ruby/missing.h: removed __linux__. it's unnecessary.
+
+Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * thread.c: disabled _FORTIFY_SOURCE for avoid to hit glibc bug.
+ [Bug #8080] [ruby-core:53349]
+ * test/ruby/test_io.rb (TestIO#test_io_select_with_many_files):
+ test for the above.
+
+Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * include/ruby/missing.h (__syscall): moved to...
+ * io.c: here. because __syscall() is only used from io.c.
+
+ * include/ruby/missing.h: move "#include <sys/type.h>" to ....
+ * include/ruby/intern.h: here. because it was introduced for
+ fixing NFDBITS issue. [ruby-core:05179].
+
+Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * include/ruby/missing.h (struct timespec): include <sys/time.h>
+
+Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * configure.in: check struct timeval exist or not.
+ * include/ruby/missing.h (struct timeval): check HAVE_STRUCT_TIMEVAL
+ properly. and don't include sys/time.h if struct timeval exist.
+
+ * file.c: include sys/time.h explicitly.
+ * random.c: ditto.
+ * thread_pthread.c: ditto.
+ * time.c: ditto.
+ * ext/date/date_strftime.c: ditto.
+
Thu Mar 28 18:54:31 2013 NAKAMURA Usaku <usa@ruby-lang.org>
* regcomp.c (optimize_node_left, set_optimize_info_from_tree): right
diff --git a/configure.in b/configure.in
index c64d981006..6305a20761 100644
--- a/configure.in
+++ b/configure.in
@@ -1098,6 +1098,7 @@ main()
ac_cv_func_fcntl=yes
ac_cv_func_flock=yes
rb_cv_large_fd_select=yes
+ ac_cv_type_struct_timeval=yes
AC_LIBOBJ([langinfo])
: ${enable_win95=maybe}
],
@@ -1192,6 +1193,13 @@ AC_CHECK_MEMBERS([struct stat.st_ctim])
AC_CHECK_MEMBERS([struct stat.st_ctimespec])
AC_CHECK_MEMBERS([struct stat.st_ctimensec])
+AC_CHECK_TYPES([struct timeval], [], [], [@%:@ifdef HAVE_TIME_H
+@%:@include <time.h>
+@%:@endif
+@%:@ifdef HAVE_SYS_TIME_H
+@%:@include <sys/time.h>
+@%:@endif])
+
AC_CHECK_TYPES([struct timespec], [], [], [@%:@ifdef HAVE_TIME_H
@%:@include <time.h>
@%:@endif])
diff --git a/file.c b/file.c
index fd64116d24..c60de23302 100644
--- a/file.c
+++ b/file.c
@@ -68,6 +68,10 @@ int flock(int, int);
#include <fcntl.h>
#endif
+#if defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#endif
+
#if !defined HAVE_LSTAT && !defined lstat
#define lstat stat
#endif
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 9745afdfda..6e1c2c2d90 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -31,6 +31,11 @@ extern "C" {
#else
# include <varargs.h>
#endif
+
+#if defined(HAVE_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
#include "ruby/st.h"
#if defined __GNUC__ && __GNUC__ >= 4
diff --git a/include/ruby/missing.h b/include/ruby/missing.h
index bded5521d1..d2cacd2706 100644
--- a/include/ruby/missing.h
+++ b/include/ruby/missing.h
@@ -24,18 +24,21 @@ extern "C" {
#include RUBY_EXTCONF_H
#endif
+#if !defined(HAVE_STRUCT_TIMEVAL) || !defined(HAVE_STRUCT_TIMESPEC)
+#if defined(HAVE_TIME_H)
+# include <time.h>
+#endif
#if defined(HAVE_SYS_TIME_H)
-# include <sys/time.h>
-#elif !defined(_WIN32)
-# define time_t long
+# include <sys/time.h>
+#endif
+#endif
+
+#if !defined(HAVE_STRUCT_TIMEVAL)
struct timeval {
time_t tv_sec; /* seconds */
long tv_usec; /* microseconds */
};
-#endif
-#if defined(HAVE_SYS_TYPES_H)
-# include <sys/types.h>
-#endif
+#endif /* HAVE_STRUCT_TIMEVAL */
#if !defined(HAVE_STRUCT_TIMESPEC)
struct timespec {
diff --git a/io.c b/io.c
index 82a24f06a8..57164d1042 100644
--- a/io.c
+++ b/io.c
@@ -102,6 +102,11 @@
# endif
#endif
+#if defined(HAVE___SYSCALL) && (defined(__APPLE__) || defined(__OpenBSD__))
+/* Mac OS X and OpenBSD have __syscall but don't define it in headers */
+off_t __syscall(quad_t number, ...);
+#endif
+
#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
#define IO_RBUF_CAPA_MIN 8192
diff --git a/random.c b/random.c
index f710286373..078d96e723 100644
--- a/random.c
+++ b/random.c
@@ -73,6 +73,9 @@ The original copyright notice follows.
#endif
#include <math.h>
#include <errno.h>
+#if defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#endif
#ifdef _WIN32
# if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0400
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 074fdee23a..ad9b80faec 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2121,4 +2121,30 @@ End
assert_equal(1, $stdout.fileno)
assert_equal(2, $stderr.fileno)
end
+
+ def test_io_select_with_many_files
+ bug8080 = '[ruby-core:53349]'
+
+ assert_normal_exit %q{
+ require "tempfile"
+
+ # try to raise RLIM_NOFILE to >FD_SETSIZE
+ # Unfortunately, ruby export FD_SETSIZE. then we assume it's 1024.
+ fd_setsize = 1024
+
+ begin
+ Process.setrlimit(Process::RLIMIT_NOFILE, fd_setsize+10)
+ rescue =>e
+ # Process::RLIMIT_NOFILE couldn't be raised. skip the test
+ exit 0
+ end
+
+ tempfiles = []
+ (0..fd_setsize+1).map {|i|
+ tempfiles << Tempfile.open("test_io_select_with_many_files")
+ }
+
+ IO.select(tempfiles)
+ }, bug8080
+ end
end
diff --git a/thread.c b/thread.c
index 5b8bc5fefb..387bf1ff72 100644
--- a/thread.c
+++ b/thread.c
@@ -42,6 +42,19 @@
*/
+/*
+ * FD_SET, FD_CLR and FD_ISSET have a small sanity check when using glibc
+ * 2.15 or later and set _FORTIFY_SOURCE > 0.
+ * However, the implementation is wrong. Even though Linux's select(2)
+ * support large fd size (>FD_SETSIZE), it wrongly assume fd is always
+ * less than FD_SETSIZE (i.e. 1024). And then when enabling HAVE_RB_FD_INIT,
+ * it doesn't work correctly and makes program abort. Therefore we need to
+ * disable FORTY_SOURCE until glibc fixes it.
+ */
+#undef _FORTIFY_SOURCE
+#undef __USE_FORTIFY_LEVEL
+#define __USE_FORTIFY_LEVEL 0
+
/* for model 2 */
#include "eval_intern.h"
diff --git a/thread_pthread.c b/thread_pthread.c
index 7631ef56a3..2cfceef936 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -24,6 +24,9 @@
#elif HAVE_SYS_FCNTL_H
#include <sys/fcntl.h>
#endif
+#if defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#endif
static void native_mutex_lock(pthread_mutex_t *lock);
static void native_mutex_unlock(pthread_mutex_t *lock);
diff --git a/time.c b/time.c
index 755812f00e..d38d2bec38 100644
--- a/time.c
+++ b/time.c
@@ -27,6 +27,10 @@
#include <strings.h>
#endif
+#if defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#endif
+
#include "timev.h"
static ID id_divmod, id_mul, id_submicro, id_nano_num, id_nano_den, id_offset;
diff --git a/version.h b/version.h
index dd6bdd9e47..bd85d75791 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 399
+#define RUBY_PATCHLEVEL 400
#define RUBY_RELEASE_DATE "2013-03-28"
#define RUBY_RELEASE_YEAR 2013
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
index e064b132e5..135c2dbcac 100644
--- a/win32/Makefile.sub
+++ b/win32/Makefile.sub
@@ -537,11 +537,13 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
#define HAVE_FCNTL_H 1
#define HAVE_SYS_UTIME_H 1
#define HAVE_FLOAT_H 1
+#define HAVE_TIME_H 1
#define rb_pid_t int
#define rb_gid_t int
#define rb_uid_t int
#define HAVE_STRUCT_STAT_ST_RDEV 1
#define HAVE_ST_RDEV 1
+#define HAVE_STRUCT_TIMEVAL 1
!if $(MSC_VER) >= 1600
#define HAVE_STDINT_H 1
!else