[Title] Syncronized reading snapshot information, and avoid duplicating insert os...
authordonghyuk.yang <donghyuk.yang@samsung.com>
Tue, 21 Aug 2012 08:27:47 +0000 (17:27 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Tue, 21 Aug 2012 08:27:47 +0000 (17:27 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

src/pkg_server/client.rb

index b6cfdeef0503cbcddb835087aa67cc063755edfb..8d7e70b8534c1353100d7153d87cbae5401bf746 100644 (file)
@@ -42,8 +42,7 @@ require "log"
 require "Version"
 require "net/ftp"
 $update_mutex = Mutex.new
-$update_os_mutex = Mutex.new
-$install_pkg_mutex = Mutex.new
+$get_snapshot_mutex = Mutex.new
 class Client
 
     # constant
@@ -104,7 +103,9 @@ class Client
            @log = logger
                end
 
-               @snapshot_path = get_lastest_snapshot(@is_server_remote)
+               $get_snapshot_mutex.synchronize {
+                       @snapshot_path = get_lastest_snapshot(@is_server_remote)
+               }                       
                @log.info "The lastest snapshot : #{@snapshot_path}"
                if @snapshot_path.nil? then 
                        @log.warn "Failed to get the lastest package list"
@@ -123,7 +124,6 @@ class Client
     public
     # update package list from server
     def update()
-               
                exists_snapshot = false
                if is_snapshot_exist(@snapshot_path) then 
                        @log.info "Snapshot information is already cached [#{get_pkglist_path()}]"                              
@@ -1520,7 +1520,8 @@ class Client
                if File.exist? local_file_path then
             File.open(local_file_path, "r") do |f|
                 f.each_line do |l|
-                    @support_os_list.push(l.strip)
+                                       os = l.strip
+                                       if @support_os_list.index(os).nil? then @support_os_list.push(os) end
                 end
                        end
                        @log.info "Get supported os infomation.. OK"
@@ -1547,7 +1548,8 @@ class Client
         if File.exist? local_file_path then
             File.open(local_file_path, "r") do |f|
                 f.each_line do |l|
-                    @archive_pkg_list.push(l.strip)
+                                       pkg = l.strip                                           
+                                       if @archive_pkg_list.index(pkg).nil? then @archive_pkg_list.push(pkg) end
                 end
                        end
                        @log.info "Get archive package infomation.. OK"