[Title] Added thread mutex on DB access
authordonghee yang <donghee.yang@samsung.com>
Fri, 5 Apr 2013 01:47:30 +0000 (10:47 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Fri, 5 Apr 2013 01:47:30 +0000 (10:47 +0900)
src/build_server/BuildServer.rb

index c3c56eb1a8ad80c9fddb091d6bcc3e49966988f0..118775948e80431f7d3fad6b749b2f72161a113f 100644 (file)
@@ -108,6 +108,7 @@ class BuildServer
                @db_passwd = nil
                @db_version = 3
                @sqlite3_db_mutex = Mutex.new
+               @db_transaction_mutex = Mutex.new
 
                #DB upgrade SQL command
                @db_migrate = []
@@ -722,9 +723,11 @@ class BuildServer
                                        @db = DBI.connect("DBI:#{@db_dsn}", @db_user, @db_passwd)
                                end
                        end
-                       @db['AutoCommit'] = false
-                       @db.transaction do |dbh|
-                               yield dbh if block_given?
+                       @db_transaction_mutex.synchronize do 
+                               @db['AutoCommit'] = false
+                               @db.transaction do |dbh|
+                                       yield dbh if block_given?
+                               end
                        end
 
                        return true