summaryrefslogtreecommitdiff
path: root/thread_pthread.c
AgeCommit message (Collapse)Author
2011-10-22* include/ruby/intern.h (rb_fd_set_cloexec): declared.akr
* 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-09-27* thread_pthread.c: make native_fd_select().kosaki
* 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-21* thread_pthread.c (ubf_select): activate timer thread when interruptnagachika
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-08-05* thread_pthread.c: fix typo.mrkn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-04* thread_pthread.c (native_cond_signal): retry to call pthread_cond_signalmrkn
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-07-19* io.c (rb_update_max_fd): new function.akr
* 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-10 * thread_pthread.c (get_stack): need to adjust stack addr forkanemoto
[Bug #1813] on AIX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10* thread_pthread.c (rb_thread_create_timer_thread): removedkosaki
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* thread_pthread.c (mutex_debug): use exit(EXIT_FAILURE) instad ofkosaki
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-08* thread_pthread.c (gvl_destroy): fix cond_t leak.kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-04* thread_pthread.c (native_sleep): cut the waiting time up tomame
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* thread_pthread.c (get_stack): For NetBSD/FreeBSD, usekosaki
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-04comment fix.kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-04* thread_pthread.c (thread_start_func_1): suppress an unused variable.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-03* thread_pthread.c (get_stack): the return address of get_stacknaruse
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* include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,ko1
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-02* thread_pthread.c (get_stack): pthread_attr_getstack() doesn'tkosaki
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* thread_pthread.c (get_stack): add to a care of gurad page on Mackosaki
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-06-30* error.c, thread_pthread.c (WRITE_CONST): suppress warningsnobu
`ignoring return value'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30* thread_pthread.c (thread_timer): ignore unknown errno.ko1
(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* thread_pthread.c (ping_signal_thread_list, thread_timer):ko1
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* thread_pthread.c (rb_thread_create_timer_thread): allocateko1
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-28* thread_pthread.c (native_stop_timer_thread): skip to closeko1
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* error.c (rb_async_bug_errno): async-safe bug report function.ko1
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* thread_pthread.c (consume_communication_pipe):ko1
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-27Temporary hack for SIGILL of miniruby on FreeBSD.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27* thread_pthread.c (consume_communication_pipe): don't use C99kosaki
style variable length array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27* thread_pthread.c (consume_communication_pipe): change returnkosaki
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* thread_pthread.c: s/__gvl_acquire/gvl_acquire_common/ andkosaki
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-27Addtitional fix for previous commit.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27* thread_pthread.c (rb_thread_create_timer_thread):naruse
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* thread_pthread.c (rb_thread_create_timer_thread):ko1
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* thread_pthread.c: Stop polling in the timer thread when there areko1
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-20* thread_pthread.c (thread_timer): rename timeout_10ms tokosaki
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-18* thread_pthread.c: remove GVL_DEBUGkosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18* internal.h: declare more internal functions.akr
* 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-16* thread_pthread.c, thread_pthread.h: remove unused variables.ko1
(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* thread_pthread.c (native_thread_create): fix debug message.ko1
(add last newline) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16* fix for build on solaris 10.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-14* thread_pthread.c (gvl_yield): fix live lock issue on 1-2 cpuskosaki
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-13* thread.c (rb_thread_schedule_rec): call gvl_yield() unconditionally.kosaki
* 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* thread_pthread.c: rewrite GVL completely.kosaki
* 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-11* thread_pthread.c (native_cond_timeout): wrap conditinally used label.nobu
* 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-05* thread_pthread.c (thread_timer): add to care a spurious wakeup.kosaki
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-01* thread_pthread.c (native_sleep): fix 1000times calculation error.kosaki
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* thread_pthread.c: remove unused macro.kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-08* thread_pthread.c (native_cond_timedwait): add to care EINTR.kosaki
* thread_pthread.c (thread_timer): remove EINTR check. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-08revert r31474. we cann't call xmalloc under FGLOCK.kosaki
Thansk, nagachika-san. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-08* thread_pthread.c (add_signal_thread_list): use xmalloc insteadkosaki
of malloc. * thread_pthread.c (remove_signal_thread_list): use xfree instead of free. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-08* thread_pthread.c: cleanup signal_thread_list related ifdef.kosaki
1) we don't have to use #ifdef FOO-PLATFORM directly 2) About half #ifdef didn't care symbian properly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e