Copy d_domain before iterating
Prevents a bug where the thread can crash due to a change in the d_domain object while running the for loop. By copying and iterating over the copy, this becomes safer.
This commit is contained in:
		| @@ -1326,7 +1326,9 @@ def collect_vm_stats(queue): | |||||||
|     # Toggle state management of dead VMs to restart them |     # Toggle state management of dead VMs to restart them | ||||||
|     if debug: |     if debug: | ||||||
|         logger.out("Toggle state management of dead VMs to restart them", state='d', prefix='vm-thread') |         logger.out("Toggle state management of dead VMs to restart them", state='d', prefix='vm-thread') | ||||||
|     for domain, instance in this_node.d_domain.items(): |     # Make a copy of the d_domain; if not, and it changes in flight, this can fail | ||||||
|  |     fixed_d_domain = this_node.d_domain.copy() | ||||||
|  |     for domain, instance in fixed_d_domain.items(): | ||||||
|         if domain in this_node.domain_list: |         if domain in this_node.domain_list: | ||||||
|             # Add the allocated memory to our memalloc value |             # Add the allocated memory to our memalloc value | ||||||
|             memalloc += instance.getmemory() |             memalloc += instance.getmemory() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user