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
This commit is contained in:
usa 2013-03-28 10:10:00 +00:00
parent ee09f19fdb
commit b97e925571
13 changed files with 120 additions and 8 deletions

View file

@ -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

View file

@ -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])

4
file.c
View file

@ -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

View file

@ -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

View file

@ -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 {

5
io.c
View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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);

4
time.c
View file

@ -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;

View file

@ -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

View file

@ -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