Skip to content
Commits on Nov 30, 2015
  1. @kosaki

    * thread_pthread.c (register_ubf_list): renamed from

    kosaki committed Nov 30, 2015
      add_signal_thread_list.
    * thread_pthread.c (unregister_ubf_list): renamed
      from remove_signal_thread_list.
    * thread_pthread.c (ubf_wakeup_all_threads): renamed from
      ping_signal_thread_list.
    * thread_pthread.c (ubf_wakeup_thread): renamed from
      ubf_select_each.
    * thread_pthread.c (ubf_threads_empty): renamed from
      check_signal_thread_list().
    * thread_pthread.c (ubf_list_lock): renamed from
      signal_thread_list_lock.
    
    * thread_pthread.c (register_ubf_list): large simplification
      by using ccan/list.h.
      bonus: removed malloc() and exit(EXIT_FAILURE).
    * thread_pthread.c (unregister_ubf_list): ditto.
    * thread_pthread.c (ubf_threads_empty): ditto.
    * thread_pthread.c (ubf_wakeup_all_threads): ditto.
    
    * thread_pthread.c (print_signal_list): removed.
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Aug 14, 2015
  1. improve handling of timer thread shutdown

    normal committed Aug 14, 2015
    Shutting down the timer thread now always closes pipes to free FDs.
    In fact, we close the write ends of the pipes is done in the main
    RubyVM to signal the timer thread shutdown.
    
    To effectively close pipes, we implement userspace locks via
    atomics to force the pipe closing thread to wait on any signal
    handlers which may be waking up.
    
    While we're at it, improve robustness during resource exhaustion and
    allow it to limp along non-fatally if restarting a timer thread
    fails.
    
    This reverts r51268
    
    Note: this change is tested with VM_CHECK_MODE 1 in vm_core.h
    
    * process.c (close_unless_reserved): add extra check
      (dup2_with_divert): remove
      (redirect_dup2): use dup2 without divert
      (before_exec_non_async_signal_safe): adjust call + comment
      (rb_f_exec): stop timer thread for all OSes
      (rb_exec_without_timer_thread): remove
    * eval.c (ruby_cleanup): adjust call
    * thread.c (rb_thread_stop_timer_thread): always close pipes
    * thread_pthread.c (struct timer_thread_pipe): add writing field,
        mark owner_process volatile for signal handlers
      (rb_thread_wakeup_timer_thread_fd): check valid FD
      (rb_thread_wakeup_timer_thread): set writing flag to prevent close
      (rb_thread_wakeup_timer_thread_low): ditto
      (CLOSE_INVALIDATE): new macro
      (close_invalidate): new function
      (close_communication_pipe): removed
      (setup_communication_pipe_internal): make errors non-fatal
      (setup_communication_pipe): ditto
      (thread_timer): close reading ends inside timer thread
      (rb_thread_create_timer_thread): make errors non-fatal
      (native_stop_timer_thread): close write ends only, always,
       wait for signal handlers to finish
      (rb_divert_reserved_fd): remove
    * thread_win32.c (native_stop_timer_thread): adjust (untested)
      (rb_divert_reserved_fd): remove
    * vm_core.h: adjust prototype
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jul 16, 2015
  1. * process.c (redirect_dup2): when the new FD of dup2() coflicts

    ngoto committed Jul 16, 2015
      with one of the timer thread FDs, the internal FD is diverted.
      [Bug #11336] [ruby-core:69886] [Bug #11350] [ruby-core:69961]
        
    * process.c (dup2_with_divert): new function for the above purpose.
       
    * thread_pthread.c (rb_divert_reserved_fd): new function for
      diverting reserved FD. If the given FD is the same as one of the
      reserved FDs, the reserved FD number is internally changed.
      It returns -1 when error. Otherwise, returns 0. It also returns
      0 if there is no need to change reserved FD number.
    
    * thread_win32.c (rb_divert_reserved_fd): always returns 0 because
      of no reserved FDs.
    
    * internal.h (rb_divert_reserved_fd): prototype declaration.
      It is Ruby internal use only.
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Sep 21, 2014
  1. @akr

    * thread_pthread.c (native_set_thread_name): New function to

    akr committed Sep 21, 2014
      set thread name visible with ps command on GNU/Linux.
      Ex. ps -o %c -L
    
    * thread.c (thread_start_func_2): Call native_set_thread_name at
      beginning.
      (rb_thread_inspect_msg): Extract from rb_thread_inspect.
    
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jun 11, 2014
  1. @nobu

    thread_pthread.c: timer thread flag

    nobu committed Jun 11, 2014
    * thread_pthread.c (timer_thread): add a flag to tell timer thread
      is created, since 0 may be a valid value as pthread_t.
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on May 15, 2014
  1. @nobu

    Handle machine stack overflow on mingw

    nobu committed May 15, 2014
    * thread_win32.c (rb_w32_stack_overflow_handler): use Structured
      Exception Handling by Addvectoredexceptionhandler() for machine
      stack overflow on mingw.
      This would be equivalent to the handling using __try and __exept
      on mswin introduced by r43748.
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on May 9, 2014
  1. @nobu

    thread_*.c: constify

    nobu committed May 9, 2014
    * thread_{pthread,win32}.c (native_cond_timedwait): constify.
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jan 28, 2014
  1. @nobu

    vm_core.h: rb_thread_struct::machine

    nobu committed Jan 28, 2014
    * vm_core.h (rb_thread_struct): aggregate cpu stuff into a struct,
      so that a debugger can show its content at once.
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Nov 21, 2013
  1. @unak

    * eval_intern.h (SAVE_ROOT_JMPBUF): workaround for the failure of

    unak committed Nov 21, 2013
      test/ruby/test_exception.rb on Windows.
      wrap by __try and __exception statements on mswin to raise SIGSEGV
      when EXCEPTION_STACK_OVERFLOW is occurred, because MSVCRT doesn't
      handle the exception.
      however, (1) mingw-gcc doesn't support __try and __exception
      statements, and (2) we cannot retry SystemStackError after this
      change yet (maybe crashed) because SEH and longjmp() are too
      uncongenial.
    
    * signal.c (check_stack_overflow, CHECK_STACK_OVERFLOW): now defined on
      Windows, too.
    
    * thread_win32.c (ruby_stack_overflowed_p): ditto.
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jul 23, 2013
  1. @ko1

    * thread_(pthread|win32).h: rename rb_thread_cond_t to

    ko1 committed Jul 23, 2013
      rb_nativethread_cond_t.
    * thread.c, thread_pthread.c, thread_win32.c, vm_core.h: catch up
      renaming.
    
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  2. @ko1

    * thread_native.h: add rb_nativethread_self() which returns

    ko1 committed Jul 23, 2013
      current running native thread identifier.
    * thread_[pthread|win32].c: implement rb_nativethread_self().
    
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  3. @ko1

    * thread_native.h: added.

    ko1 committed Jul 23, 2013
      Move native thread related lines from vm_core.h.
      And declare several functions "rb_nativethread_lock_*",
      manipulate locking.
    * common.mk: add thread_native.h.
    * thread.c: add functions "rb_nativethread_lock_*".
    * thraed.c, thread_[pthread,win32].[ch]: rename rb_thread_lock_t
      to rb_nativethread_lock_t to make it clear that this lock is for
      native thraeds, not for ruby threads.
    
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jul 8, 2013
  1. @nobu

    win32: for strict ANSI

    nobu committed Jul 8, 2013
    * thread_win32.c (w32_thread_start_func, thread_start_func_1),
      (timer_thread_func): use __stdcall instead of _stdcall which is
      unavailable in strict ANSI mode.  [ruby-core:55312] [Bug #8495]
    * win32/win32.c (gettimeofday): use __cdecl instead of _cdecl.
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Mar 30, 2013
  1. @nobu

    timev.h: move time_t stuffs

    nobu committed Mar 30, 2013
    * timev.h (TYPEOF_TIMEVAL_TV_SEC, unsigned_time_t): move from time.c.
    
    * thread.c: use definitions in timev.h.
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Mar 26, 2013
  1. @akr

    * internal.h: Define TIMET_MAX and TIMET_MIN here.

    akr committed Mar 26, 2013
    * time.c: Remove TIMET_MAX and TIMET_MIN definitions.
    
    * thread.c: Ditto.
    
    * thread_pthread.c: Remove TIMET_MAX definition.
    
    * thread_win32.c: Ditto.
    
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Mar 21, 2013
  1. @nobu

    * thread_win32.c (native_sleep): suppress warning.

    nobu committed Mar 21, 2013
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Feb 27, 2013
  1. @nobu

    thread_win32.c: suppress warning

    nobu committed Feb 27, 2013
    * thread_win32.c (native_sleep): constify local variable to suppress a
      false positive might-be-clobbered warning.
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Nov 28, 2012
  1. @ko1

    * thread_win32.c: catch up latest change of BLOCKING_REGION.

    ko1 committed Nov 28, 2012
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jun 17, 2012
  1. @nobu

    thread_win32.h: rb_thread_lock_t for USE_WIN32_MUTEX

    nobu committed Jun 17, 2012
    * thread_win32.h (rb_thread_lock_t): make a union for USE_WIN32_MUTEX.
      this internal is used only in thread_win32.c, but has to be complete
      to define rb_thread_t.
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  2. @nobu

    thread_win32.c: USE_WIN32_MUTEX

    nobu committed Jun 17, 2012
    * thread_win32.c (native_mutex_lock, native_mutex_destroy): fix for
      USE_WIN32_MUTEX.
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  3. @nobu

    thread_win32.c: reserved pattern name

    nobu committed Jun 17, 2012
    * thread_win32.c (native_cond_timedwait_ms): rename reserved pattern
      name.  user defined symbols should not start with __.
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jun 8, 2012
  1. @unak

    * thread_win32.c (native_thread_create): add a comment.

    unak committed Jun 8, 2012
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Mar 29, 2012
  1. @unak

    * thread_win32.c (TIME_QUANTUM_USEC): 10ms(= old setting) [experimental]

    unak committed Mar 29, 2012
      cf. [Bug #6098]
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jan 28, 2012
  1. @shirosaki

    * thread_win32.c (rb_w32_wait_events_blocking): use

    shirosaki committed Jan 28, 2012
      ruby_thread_from_native() instead of GET_THREAD() because
      GET_THREAD() doesn't always return the current thread and
      WaitForMultipleObjects() at rb_w32_read() doesn't return by
      Thread#kill. This fixes TestQueue#test_thr_kill failure on
      Windows.
    
    * thread_win32.c (rb_w32_wait_events): use ruby_thread_from_native()
      instead of GET_THREAD() for consistency with the above change.
    
    * thread_win32.c (rb_w32_sleep): ditto.
    
    * thread_win32.c (rb_w32_Sleep): ditto.
      [ruby-dev:45149] [Bug #5812]
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jul 3, 2011
  1. @ko1

    * include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,

    ko1 committed Jul 3, 2011
      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
Commits on Jun 28, 2011
  1. @unak

    * thread_win32.c (native_stop_timer_thread): fixed commit miss of

    unak committed Jun 28, 2011
      r32244.  grep sources before changing the signature of a function.
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jun 27, 2011
  1. @ko1

    * thread_pthread.c: Stop polling in the timer thread when there are

    ko1 committed Jun 27, 2011
      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
Commits on Jun 15, 2011
  1. @unak

    * thread.c (do_select): Windows: no need to poll if select(2) is

    unak committed Jun 15, 2011
      cancelable.
    
    * thread_win32.c (native_fd_select): new function to make select(2)
      cancelable.
    
    * thread_win32.c (rb_w32_check_interrupt): new function for checking
      interrupt.
    
    * win32/win32.c (rb_w32_select_with_thread): new function. cancelable
      select(2).
    
    * win32/win32.c (rb_w32_select): use above function internally.
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jun 13, 2011
  1. @kosaki

    * thread.c (rb_thread_schedule_rec): call gvl_yield() unconditionally.

    kosaki committed Jun 13, 2011
    * 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
  2. @kosaki

    * thread_pthread.c: rewrite GVL completely.

    kosaki committed Jun 13, 2011
    * 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
  3. @kosaki

    * thread_win32.c (native_cond_signal): remove unnecessary rb_bug().

    kosaki committed Jun 13, 2011
      It's addional fix for r32021. [Bug #4696]
    
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on Jun 12, 2011
  1. @nobu

    * atomic.h (ATOMIC_OR): _InterlockedOr is not available on migw.

    nobu committed Jun 12, 2011
    * gc.c (rb_gc_set_params): VM_OBJSPACE is disabled on mignw.
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Commits on May 7, 2011
  1. @kosaki

    remove debugging code

    kosaki committed May 7, 2011
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  2. @kosaki

    fix win32 native_cond_timedwait() makes SIGSEGV.

    kosaki committed May 7, 2011
    * thread_win32.h (rb_thread_cond_struct): add prev field instead of last.
      (ie cond_event_entry is now using double linked list instead of single)
    * thread_win32.c (cond_event_entry): add prev field.
    
    * thread_win32.c (__cond_timedwait): remove entry properly if timeout
      was happen.
    
    * thread_win32.c (native_cond_signal): change for double linked list.
    * thread_win32.c (native_cond_broadcast): ditto.
    * thread_win32.c (native_cond_initialize): ditto.
    
    
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  3. @kosaki

    fix mutex deadlock test hang-up.

    kosaki committed May 7, 2011
    * thread_win32.c (abs_timespec_to_timeout_ms): fix 1000x calculation
      mistake. (ie fix hang-up native_cond_timedwait())
    
    
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Something went wrong with that request. Please try again.