OSDN Git Service

The wrong lock position may cause ThreadError because another (not-owner) thread...
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Wed, 22 Aug 2007 13:34:28 +0000 (13:34 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Wed, 22 Aug 2007 13:34:28 +0000 (13:34 +0000)
shogi-server

index 96d3349..4a10a59 100755 (executable)
@@ -428,12 +428,13 @@ class Player < BasicPlayer
   def run(csa_1st_str=nil)
     while (csa_1st_str || (str = @socket.gets_safe(Default_Timeout)))
       begin
+        $mutex.lock
+
         if (@writer_thread == nil || @writer_thread.status == false)
           # The writer_thread has been killed because of socket errors.
           return
         end
 
-        $mutex.lock
         if (csa_1st_str)
           str = csa_1st_str
           csa_1st_str = nil