diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-28 10:10:00 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-28 10:10:00 +0000 |
commit | b97e925571e32dff40573af7991d7dfe7fc9c7ce (patch) | |
tree | a351603c55aaffc8754d3d323b03a819288cb5cf | |
parent | ee09f19fdbf047a31ec1c85e6f53ea4a67ded48c (diff) |
merge revision(s) 39772,39773,39774,39775,39777,39779,39781,39783: [Backport #8080]
* 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.
* include/ruby/missing.h (struct timespec): include <sys/time.h>
* 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].
* 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.
* include/ruby/missing.h: removed __linux__. it's unnecessary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@39985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 36 | ||||
-rw-r--r-- | configure.in | 8 | ||||
-rw-r--r-- | file.c | 4 | ||||
-rw-r--r-- | include/ruby/intern.h | 5 | ||||
-rw-r--r-- | include/ruby/missing.h | 17 | ||||
-rw-r--r-- | io.c | 5 | ||||
-rw-r--r-- | random.c | 3 | ||||
-rw-r--r-- | test/ruby/test_io.rb | 26 | ||||
-rw-r--r-- | thread.c | 13 | ||||
-rw-r--r-- | thread_pthread.c | 3 | ||||
-rw-r--r-- | time.c | 4 | ||||
-rw-r--r-- | version.h | 2 | ||||
-rw-r--r-- | win32/Makefile.sub | 2 |
13 files changed, 120 insertions, 8 deletions
@@ -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]) @@ -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 { @@ -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 @@ -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 @@ -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); @@ -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; @@ -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 |