ruby-changes:27933
From: usa <ko1@a...>
Date: Thu, 28 Mar 2013 19:10:14 +0900 (JST)
Subject: [ruby-changes:27933] usa:r39985 (ruby_1_9_3): merge revision(s) 39772,39773,39774,39775,39777,39779,39781,39783: [Backport #8080]
usa 2013-03-28 19:10:00 +0900 (Thu, 28 Mar 2013) New Revision: 39985 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39985 Log: 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. Modified directories: branches/ruby_1_9_3/ Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/configure.in branches/ruby_1_9_3/file.c branches/ruby_1_9_3/include/ruby/intern.h branches/ruby_1_9_3/include/ruby/missing.h branches/ruby_1_9_3/io.c branches/ruby_1_9_3/random.c branches/ruby_1_9_3/test/ruby/test_io.rb branches/ruby_1_9_3/thread.c branches/ruby_1_9_3/thread_pthread.c branches/ruby_1_9_3/time.c branches/ruby_1_9_3/version.h branches/ruby_1_9_3/win32/Makefile.sub Index: ruby_1_9_3/time.c =================================================================== --- ruby_1_9_3/time.c (revision 39984) +++ ruby_1_9_3/time.c (revision 39985) @@ -27,6 +27,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/time.c#L27 #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; Index: ruby_1_9_3/include/ruby/intern.h =================================================================== --- ruby_1_9_3/include/ruby/intern.h (revision 39984) +++ ruby_1_9_3/include/ruby/intern.h (revision 39985) @@ -31,6 +31,11 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/include/ruby/intern.h#L31 #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 Index: ruby_1_9_3/include/ruby/missing.h =================================================================== --- ruby_1_9_3/include/ruby/missing.h (revision 39984) +++ ruby_1_9_3/include/ruby/missing.h (revision 39985) @@ -24,18 +24,21 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/include/ruby/missing.h#L24 #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 { Index: ruby_1_9_3/configure.in =================================================================== --- ruby_1_9_3/configure.in (revision 39984) +++ ruby_1_9_3/configure.in (revision 39985) @@ -1098,6 +1098,7 @@ main() https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/configure.in#L1098 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]) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/configure.in#L1193 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]) Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 39984) +++ ruby_1_9_3/ChangeLog (revision 39985) @@ -1,3 +1,39 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1 +Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@g...> + + * include/ruby/missing.h: removed __linux__. it's unnecessary. + +Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@g...> + + * 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@g...> + + * 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@g...> + + * include/ruby/missing.h (struct timespec): include <sys/time.h> + +Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@g...> + + * 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@r...> * regcomp.c (optimize_node_left, set_optimize_info_from_tree): right Index: ruby_1_9_3/thread_pthread.c =================================================================== --- ruby_1_9_3/thread_pthread.c (revision 39984) +++ ruby_1_9_3/thread_pthread.c (revision 39985) @@ -24,6 +24,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/thread_pthread.c#L24 #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); Index: ruby_1_9_3/io.c =================================================================== --- ruby_1_9_3/io.c (revision 39984) +++ ruby_1_9_3/io.c (revision 39985) @@ -102,6 +102,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/io.c#L102 # 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 Index: ruby_1_9_3/thread.c =================================================================== --- ruby_1_9_3/thread.c (revision 39984) +++ ruby_1_9_3/thread.c (revision 39985) @@ -42,6 +42,19 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/thread.c#L42 */ +/* + * 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" Index: ruby_1_9_3/win32/Makefile.sub =================================================================== --- ruby_1_9_3/win32/Makefile.sub (revision 39984) +++ ruby_1_9_3/win32/Makefile.sub (revision 39985) @@ -537,11 +537,13 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/win32/Makefile.sub#L537 #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 Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 39984) +++ ruby_1_9_3/version.h (revision 39985) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1 #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 Index: ruby_1_9_3/test/ruby/test_io.rb =================================================================== --- ruby_1_9_3/test/ruby/test_io.rb (revision 39984) +++ ruby_1_9_3/test/ruby/test_io.rb (revision 39985) @@ -2121,4 +2121,30 @@ End https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_io.rb#L2121 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 Index: ruby_1_9_3/file.c =================================================================== --- ruby_1_9_3/file.c (revision 39984) +++ ruby_1_9_3/file.c (revision 39985) @@ -68,6 +68,10 @@ int flock(int, int); https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/file.c#L68 #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 Index: ruby_1_9_3/random.c =================================================================== --- ruby_1_9_3/random.c (revision 39984) +++ ruby_1_9_3/random.c (revision 39985) @@ -73,6 +73,9 @@ The original copyright notice follows. https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/random.c#L73 #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 Property changes on: ruby_1_9_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r39772-39775,39777,39779,39781,39783 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/