[前][次][番号順一覧][スレッド一覧]

ruby-changes:26349

From: kosaki <ko1@a...>
Date: Sat, 15 Dec 2012 14:40:30 +0900 (JST)
Subject: [ruby-changes:26349] kosaki:r38400 (trunk): * thread.c (rb_mutex_owned_p): remove static.

kosaki	2012-12-15 14:40:18 +0900 (Sat, 15 Dec 2012)

  New Revision: 38400

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38400

  Log:
    * thread.c (rb_mutex_owned_p): remove static.
    * io.c (io_flush_buffer): don't hold mutex if already have.
      Now recursive lock may occur when following scenario.
      fptr_finalize -> finish_writeconv_sync -> finish_writeconv
      -> io_fflush.

  Modified files:
    trunk/ChangeLog
    trunk/internal.h
    trunk/io.c
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38399)
+++ ChangeLog	(revision 38400)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Dec 15 13:57:08 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* thread.c (rb_mutex_owned_p): remove static.
+	* io.c (io_flush_buffer): don't hold mutex if already have.
+	  Now recursive lock may occur when following scenario.
+	  fptr_finalize -> finish_writeconv_sync -> finish_writeconv
+	  -> io_fflush.
+
 Sat Dec 15 13:38:30 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* io.c (io_flush_buffer): uses io_flush_buffer_async2 instead of
Index: io.c
===================================================================
--- io.c	(revision 38399)
+++ io.c	(revision 38400)
@@ -1006,7 +1006,10 @@ static inline int https://github.com/ruby/ruby/blob/trunk/io.c#L1006
 io_flush_buffer(rb_io_t *fptr)
 {
     if (fptr->write_lock) {
-	return (int)rb_mutex_synchronize(fptr->write_lock, io_flush_buffer_async2, (VALUE)fptr);
+	if (rb_mutex_owned_p(fptr->write_lock))
+	    return (int)io_flush_buffer_async2((VALUE)fptr);
+	else
+	    return (int)rb_mutex_synchronize(fptr->write_lock, io_flush_buffer_async2, (VALUE)fptr);
     }
     else {
 	return (int)io_flush_buffer_async((VALUE)fptr);
Index: thread.c
===================================================================
--- thread.c	(revision 38399)
+++ thread.c	(revision 38400)
@@ -4264,7 +4264,7 @@ rb_mutex_lock(VALUE self) https://github.com/ruby/ruby/blob/trunk/thread.c#L4264
  * Returns +true+ if this lock is currently held by current thread.
  * <em>This API is experimental, and subject to change.</em>
  */
-static VALUE
+VALUE
 rb_mutex_owned_p(VALUE self)
 {
     VALUE owned = Qfalse;
Index: internal.h
===================================================================
--- internal.h	(revision 38399)
+++ internal.h	(revision 38400)
@@ -283,6 +283,7 @@ VALUE rb_thread_shield_release(VALUE sel https://github.com/ruby/ruby/blob/trunk/internal.h#L283
 VALUE rb_thread_shield_destroy(VALUE self);
 void rb_mutex_allow_trap(VALUE self, int val);
 VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
+VALUE rb_mutex_owned_p(VALUE self);
 
 /* thread_pthread.c, thread_win32.c */
 void Init_native_thread(void);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]