Граф коммитов

143 Коммитов

Автор SHA1 Сообщение Дата
nobu 0a420f2274 * thread_pthread.c (add_signal_thread_list): suppress warning for
unused function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-27 08:24:26 +00:00
kosaki 871c6923dc * thread_pthread.c (gvl_yield): don't prevent concurrent sched_yield().
[Bug #5130] [ruby-core:38647]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-09 17:10:48 +00:00
nobu 413f24d3b0 * whitespace cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-04 07:19:23 +00:00
akr 0d2a92e0b3 * include/ruby/intern.h (rb_cloexec_pipe): declared.
* io.c (rb_cloexec_pipe): new function.
  (rb_pipe): use rb_cloexec_pipe.

* thread_pthread.c (rb_thread_create_timer_thread): use
  rb_cloexec_pipe.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 12:13:05 +00:00
akr b574a4d4a1 * include/ruby/intern.h (rb_fd_set_cloexec): declared.
* io.c (rb_fd_set_cloexec): new function.
  (ruby_dup): call rb_fd_set_cloexec to set close-on-exec flag.
  (rb_sysopen_internal): ditto.
  (rb_pipe): ditto.
  (io_reopen): ditto.
  (io_cntl): ditto.

* process.c (rb_f_exec): change the default :close_others option to
  true.
  (rb_f_system): ditto.
  (move_fds_to_avoid_crash): call rb_fd_set_cloexec to set
  close-on-exec flag.
  (ruby_setsid): ditto.
  (rb_daemon): ditto.

* thread_pthread.c (rb_thread_create_timer_thread): call
  rb_fd_set_cloexec to set close-on-exec flag.

* ruby.c (load_file_internal): ditto.

* file.c (rb_file_s_truncate): ditto.
  (file_load_ok): ditto.

* random.c (fill_random_seed): ditto.

* ext/pty/pty.c (chfunc): ditto.
  (get_device_once): ditto.

* ext/openssl/ossl_bio.c (ossl_obj2bio): ditto.

* ext/socket/init.c (rsock_socket): ditto.
  (rsock_s_accept_nonblock): ditto.
  (rsock_s_accept): ditto.

* ext/socket/socket.c (rsock_sock_s_socketpair): ditto.

* ext/socket/ancdata.c (discard_cmsg): ditto.
  (make_io_for_unix_rights): ditto.

* ext/socket/unixsocket.c (unix_recv_io): ditto.

* ext/io/console/console.c (console_dev): ditto.

[ruby-core:38140] [Feature #5041]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-22 09:58:15 +00:00
kosaki 1bdf1a5c6f * thread_pthread.c: make native_fd_select().
* thread.c (do_select): remove #ifdef _WIN32. Instead, use
  native_fd_select() always.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-27 00:59:04 +00:00
nagachika f80896c219 * thread_pthread.c (ubf_select): activate timer thread when interrupt
blocking thread.
  A patch created by Koichi Sasada. [ruby-core:39634] [Bug #5343]
  to cover race condition, timer thread periodically send SIGVTARLM to
  threads in signal thread list. so you should activate timer thread
  when interrupt a thread.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-21 17:02:21 +00:00
mrkn 2205687ccf * thread_pthread.c: fix typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-05 01:11:12 +00:00
mrkn 6a7081bb18 * thread_pthread.c (native_cond_signal): retry to call pthread_cond_signal
and pthread_cond_broadcast if they return EAGAIN in
  native_cond_signal and native_cond_broadcast, respectively.
  It is for the pthread implementation of Mac OS X 10.7 (Lion).
  fixes #5155.  [ruby-dev:44342].
* thread_pthread.c (native_cond_broadcast): ditto.
* thread_pthread.c (struct cached_thread_entry): stop using
  pthread_cond_t and its functions directly.
* thread_pthread.c (register_cached_thread_and_wait): ditto.
* thread_pthread.c (use_cached_thread): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-04 15:06:20 +00:00
akr 2c7576a021 * io.c (rb_update_max_fd): new function.
* internal.h (rb_update_max_fd): declare rb_update_max_fd.

* thread_pthread.c (rb_thread_create_timer_thread): update max fd when
  timer thread pipe is created.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-19 07:10:19 +00:00
kanemoto e4c452daf8 * thread_pthread.c (get_stack): need to adjust stack addr for
[Bug #1813] on AIX.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 20:39:35 +00:00
kosaki 74b339e938 * thread_pthread.c (rb_thread_create_timer_thread): removed
rb_disable_interrupt()/rb_enable_interrupt().
* vm_core.h: ditto.
* process.c (static void before_exec): ditto.
* process.c (static void after_exec): ditto.
  [Bug #4765] [ruby-dev:43571]

* eval_intern.h: removed rb_trap_restore_mask().
* vm_eval.c (rb_throw_obj): ditto.
* eval.c (setup_exception): ditto.

* signal.c: removed trap_last_mask.
* signal.c (trap_restore_mask): removed.
* signal.c (init_sigchld): comment clarification why signal block
  is needed. and removed trap_last_mask operation.
* signal.c (trap_ensure): removed trap_last_mask operation.

* signal.c (rb_disable_interrupt, rb_enable_interrupt): made
  static and removed sigdelset(SIGVTALARM) and sigdelset(SIGSEGV).

* process.c (rb_syswait): removed implicit signal handler change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 17:04:40 +00:00
kosaki b9a13f4962 * thread_pthread.c (mutex_debug): use exit(EXIT_FAILURE) instad of
exit(1).
* thread_pthread.c (add_signal_thread_list): ditto.
* thread.c (rb_thread_call_with_gvl): ditto.
* util.c (Bug): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 08:29:46 +00:00
kosaki affa47ae4d * thread_pthread.c (gvl_destroy): fix cond_t leak.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-08 01:40:54 +00:00
mame fed26e916b * thread_pthread.c (native_sleep): cut the waiting time up to
100,000,000 because Solaris cond_timedwait() return EINVAL if an
  argument is greater than current_time + 100,000,000.  This is
  considered as a kind of spurious wakeup.  The caller to native_sleep
  should care about spurious wakeup.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-04 16:32:21 +00:00
kosaki e6d42f34e2 * thread_pthread.c (get_stack): For NetBSD/FreeBSD, use
pthread_attr_getstack() if possible. and, remove an assumption
  of stack growing direction.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-04 13:27:31 +00:00
kosaki 1e8adda1fc comment fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-04 12:58:07 +00:00
nobu 6dad6f5c4c * thread_pthread.c (thread_start_func_1): suppress an unused variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-04 06:52:35 +00:00
naruse 948f01a865 * thread_pthread.c (get_stack): the return address of get_stack
must be the highest address of the current thread's stack.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-03 22:16:02 +00:00
ko1 eb35bb0b35 * include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,
RB_RESERVED_FD_P): added.  This C API is to limit to access
  fds which are used by RubyVM internal.  In this version of
  CRuby, return 1 if fd is communication pipe.
  If your application needs to close all file descriptors to
  preent resource leak, skip internal fds using this C API.
  We also define a macro RB_RESERVED_FD_P(fd).  So you can write
  #ifndef RB_RESERVED_FD_P
  #define RB_RESERVED_FD_P(fd) 0
  #endif
  for Ruby 1.9.2 or previous version to write compatible extensions.
  See [ruby-core:37727]
* thread_win32.c (rb_reserved_fd_p): added (return 0 for any fds).
* io.c (rb_io_initialize): raise ArgumentError if given fd is reserved by Ruby.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-03 21:56:59 +00:00
kosaki 70dd402cd8 * thread_pthread.c (get_stack): pthread_attr_getstack() doesn't
return stack start addres, but stack base address. Thus,
  we need to add stack size for getting stack start address.
  And, we don't have to decrease guard size twice.
* thread_pthread.c (thread_start_func_1): don't use inaccurate
  stack start guess if native_thread_init_stack() can be used.
  [Bug #1813] [ruby-core:24540]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-02 21:18:16 +00:00
kosaki 5a73c71dcf * thread_pthread.c (get_stack): add to a care of gurad page on Mac
OS X. [Bug #1813] [ruby-core:24540]
* signal.c (ruby_signal): SIGBUS use alternative stack too.
* signal.c (sigbus): On Mac, thread stack overflow makes SIGBUS
  instead of SIGSEGV. thus, added stackoverflow check.
* signal.c (default_handler): get rid of compilation warning.
* signal.c (Init_signal): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-02 19:59:05 +00:00
nobu 8ad06e2604 * error.c, thread_pthread.c (WRITE_CONST): suppress warnings
`ignoring return value'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30 23:03:23 +00:00
ko1 fa2c1c75a9 * thread_pthread.c (thread_timer): ignore unknown errno.
(we observed that select(2) was canceled by errno=514 on
  boron == Linux/Xen environment)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30 10:11:45 +00:00
ko1 d49a61e68f * thread_pthread.c (ping_signal_thread_list, thread_timer):
fix to keep polling state if there are any ping-tasks.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30 08:27:13 +00:00
ko1 5164677841 * thread_pthread.c (rb_thread_create_timer_thread): allocate
machine stack for the timer thread at least 12KB.  FreeBSD 8.2
  AMD64 causes machine stack overflow (SIGSEGV) only with
  PTHREAD_STACK_MIN (maybe defined as 2KB).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30 03:34:16 +00:00
ko1 87dadf3b8c * thread_pthread.c (native_stop_timer_thread): skip to close
communication pipe to avoid timing bug (process termination timing).
  The communication pipe will closed by OS.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-28 21:23:40 +00:00
ko1 c22126755c * error.c (rb_async_bug_errno): async-safe bug report function.
In timer thread, signal handler shoul use it.
  The patch is contributed by Eric Wong <normalperson@yhbt.net>.
  Refs: [ruby-core:37644] and [ruby-core:37647]
* thread_pthread.c: use rb_async_bug_errno().
  And replace all fprintf() to write().
* internal.h (rb_async_bug_errno): add decl. of above func.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-28 21:17:29 +00:00
ko1 014a5f3178 * thread_pthread.c (consume_communication_pipe):
Make "buff" as static.  (Maybe) "buff" can be shared between
  any caller (any threads) because no one use the read values.
  And remove const value "buff_size", and define CCP_READ_BUFF_SIZE
  macro.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-28 02:53:15 +00:00
naruse 801bac0977 Temporary hack for SIGILL of miniruby on FreeBSD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 18:36:55 +00:00
kosaki 3639736d5d * thread_pthread.c (consume_communication_pipe): don't use C99
style variable length array.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 13:10:26 +00:00
kosaki f8cc779680 * thread_pthread.c (consume_communication_pipe): change return
type to void. caller doesn't use it.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 13:05:22 +00:00
kosaki ea3da57e12 * thread_pthread.c: s/__gvl_acquire/gvl_acquire_common/ and
s/__gvl_release/gvl_release_common/.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 12:18:00 +00:00
naruse c32869dfeb Addtitional fix for previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 02:45:30 +00:00
naruse 657e9e2879 * thread_pthread.c (rb_thread_create_timer_thread):
the type of retrun value of write(2) is ssize_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 02:43:03 +00:00
ko1 f18cf4f023 * thread_pthread.c (rb_thread_create_timer_thread):
Fixes missing initialization of oflags.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 00:59:07 +00:00
ko1 d1d5d5e798 * thread_pthread.c: Stop polling in the timer thread when there are
no waiting thread.  If there are 2 or more runnable threads,
  the timer thread does polling.  Avoid polling makes power save
  for several computers (0.2W per a Ruby process, when I measured).
  If outside-event such as signal or Thread#kill was occuerred
  when the timer thread does not do polling, then wake-up
  the timer thread using communication-pipe (the timer thread
  waits this communication-pipe with select(2)).
  The discussion about this modification can be found from the post
  [ruby-core:33456] and other related posts.
  Note that Eric Wong and KOSAKI Motohiro give us the huge
  contributions for this modification.  Thanks.
* thread_pthread.c (rb_thread_wakeup_timer_thread): add a function.
  This function wakes up the timer thread using communication-pipe.
* thread.c (rb_thread_stop_timer_thread): add a parameter which
  specify closing communication-pipe or not.
* thread.c (rb_thread_terminate_all): do not stop timer thread here
  (ruby_cleanup() terminate timer thread).
* signal.c: wake up timer thread using
  rb_thread_wakeup_timer_thread() from signal handler.
* eval.c (ruby_cleanup): use rb_thread_stop_timer_thread(1).
* process.c: use rb_thread_stop_timer_thread(0)
  (reuse communication-pipe).
* thread_win32.c (rb_thread_wakeup_timer_thread): add a dummy
  function.
* vm_core.h: add and fix decl. of functions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 00:30:41 +00:00
kosaki 2552e428f3 * thread_pthread.c (thread_timer): rename timeout_10ms to
time_quantum. it's no longer 10ms.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-20 12:32:35 +00:00
kosaki e623ceb9f9 * thread_pthread.c: remove GVL_DEBUG
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 12:39:01 +00:00
akr afd7e4668f * internal.h: declare more internal functions.
* iseq.h (rb_method_get_iseq): declared.

* compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c,
  ruby.c, time.c, util.c, vm.c: don't declare internal functions.

* eval.c, parse.y, thread_pthread.c: non-existing function declarations
  removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 01:54:57 +00:00
ko1 772a281192 * thread_pthread.c, thread_pthread.h: remove unused variables.
(native_thread_data_t::gvl_cond, native_thread_data_t::gvl_next)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16 19:52:54 +00:00
ko1 1ac74a11c2 * thread_pthread.c (native_thread_create): fix debug message.
(add last newline)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16 17:28:54 +00:00
nobu 685444569c * fix for build on solaris 10.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16 00:12:55 +00:00
kosaki 82e6d95edc * thread_pthread.c (gvl_yield): fix live lock issue on 1-2 cpus
system. It's additional fix for r32021.
* thread_pthread.c (gvl_init): add switch_wait_cond.
* thread_pthread.h (typedef struct rb_global_vm_lock_struct): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-14 16:31:23 +00:00
kosaki afd1a64cd6 * thread.c (rb_thread_schedule_rec): call gvl_yield() unconditionally.
* thread_pthread.c: remove HAVE_GVL_YIELD macro.
* thread_win32.c (gvl_yield): new. this fallback logic was moved from
  rb_thread_schedule_rec().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 15:06:30 +00:00
kosaki bcfc22b10e * thread_pthread.c: rewrite GVL completely.
* thread_win32.c: ditto.
* thread_pthread.h: ditto.
* vm_core.h: ditto.
* thread.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 14:14:53 +00:00
nobu fe244c77b0 * thread_pthread.c (native_cond_timeout): wrap conditinally used label.
* thread_pthread.c (native_sleep): remove unused variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-11 01:21:10 +00:00
kosaki 4010bc1e84 * thread_pthread.c (thread_timer): add to care a spurious wakeup.
When native_cond_timedwait() return 0 by spurious wakeup, we
  don't have to neither 1) call timer_thread_function and 2)
  exit the timer thread.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-05 12:48:23 +00:00
kosaki 859da83455 * thread_pthread.c (native_sleep): fix 1000times calculation error.
this is a regression since r31457. [Bug #4808] [ruby-dev:43606]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-01 13:03:25 +00:00
kosaki dcc1f64cb0 * thread_pthread.c: remove unused macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-01 08:20:16 +00:00