Skip to content

Commit

Permalink
fix(settings updates): muliple setting updates could clobber
Browse files Browse the repository at this point in the history
this also limits the number of writes occuring to the database from any single instance of core
  • Loading branch information
stakach committed Feb 5, 2021
1 parent b3ae85e commit 7b93722
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: placeos-driver
version: 4.1.1
version: 4.1.2

dependencies:
action-controller:
Expand Down
3 changes: 2 additions & 1 deletion src/placeos-driver/protocol/management.cr
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class PlaceOS::Driver::Protocol::Management

private getter debug_lock : Mutex = Mutex.new
private getter request_lock : Mutex = Mutex.new
private getter settings_update_lock : Mutex = Mutex.new

private getter modules : Hash(String, String) = {} of String => String
private getter events : Channel(Request) = Channel(Request).new
Expand Down Expand Up @@ -455,7 +456,7 @@ class PlaceOS::Driver::Protocol::Management
when "setting"
mod_id = request.id
setting_name, setting_value = Tuple(String, YAML::Any).from_yaml(request.payload.not_nil!)
on_setting.call(mod_id, setting_name, setting_value)
settings_update_lock.synchronize { on_setting.call(mod_id, setting_name, setting_value) }
when "hset"
# Redis proxy driver state (hash)
hash_id = request.id
Expand Down

0 comments on commit 7b93722

Please sign in to comment.