mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-30 06:50:06 +00:00 
			
		
		
		
	Elevation cuts needs protected by mutex
- If elevation cuts is read while GetLevel2Data is being called from ComputeSweep, the application will crash. - Additionally, the elevationCut_ variable should probably be made atomic.
This commit is contained in:
		
							parent
							
								
									4502b59830
								
							
						
					
					
						commit
						2cc5e48102
					
				
					 1 changed files with 14 additions and 2 deletions
				
			
		|  | @ -8,6 +8,9 @@ | ||||||
| #include <scwx/util/threads.hpp> | #include <scwx/util/threads.hpp> | ||||||
| #include <scwx/util/time.hpp> | #include <scwx/util/time.hpp> | ||||||
| 
 | 
 | ||||||
|  | #include <atomic> | ||||||
|  | #include <mutex> | ||||||
|  | 
 | ||||||
| #include <boost/range/irange.hpp> | #include <boost/range/irange.hpp> | ||||||
| #include <boost/timer/timer.hpp> | #include <boost/timer/timer.hpp> | ||||||
| 
 | 
 | ||||||
|  | @ -160,11 +163,13 @@ public: | ||||||
| 
 | 
 | ||||||
|    float                    latitude_; |    float                    latitude_; | ||||||
|    float                    longitude_; |    float                    longitude_; | ||||||
|    float                    elevationCut_; |    std::atomic<float>       elevationCut_; | ||||||
|    std::vector<float>       elevationCuts_; |    std::vector<float>       elevationCuts_; | ||||||
|    units::kilometers<float> range_; |    units::kilometers<float> range_; | ||||||
|    uint16_t                 vcp_; |    uint16_t                 vcp_; | ||||||
| 
 | 
 | ||||||
|  |    std::mutex elevationCutsMutex_ {}; | ||||||
|  | 
 | ||||||
|    std::chrono::system_clock::time_point sweepTime_; |    std::chrono::system_clock::time_point sweepTime_; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<common::ColorTable>    colorTable_; |    std::shared_ptr<common::ColorTable>    colorTable_; | ||||||
|  | @ -368,6 +373,7 @@ std::string Level2ProductView::GetRadarProductName() const | ||||||
| 
 | 
 | ||||||
| std::vector<float> Level2ProductView::GetElevationCuts() const | std::vector<float> Level2ProductView::GetElevationCuts() const | ||||||
| { | { | ||||||
|  |    const std::unique_lock lock {p->elevationCutsMutex_}; | ||||||
|    return p->elevationCuts_; |    return p->elevationCuts_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -565,11 +571,17 @@ void Level2ProductView::ComputeSweep() | ||||||
|    std::shared_ptr<wsr88d::rda::ElevationScan> radarData; |    std::shared_ptr<wsr88d::rda::ElevationScan> radarData; | ||||||
|    std::chrono::system_clock::time_point       requestedTime {selected_time()}; |    std::chrono::system_clock::time_point       requestedTime {selected_time()}; | ||||||
|    types::RadarProductLoadStatus               loadStatus {}; |    types::RadarProductLoadStatus               loadStatus {}; | ||||||
|  | 
 | ||||||
|  |    std::vector<float> newElevationCuts {}; | ||||||
|    std::tie( |    std::tie( | ||||||
|       radarData, p->elevationCut_, p->elevationCuts_, std::ignore, loadStatus) = |       radarData, p->elevationCut_, newElevationCuts, std::ignore, loadStatus) = | ||||||
|       radarProductManager->GetLevel2Data( |       radarProductManager->GetLevel2Data( | ||||||
|          p->dataBlockType_, p->selectedElevation_, requestedTime); |          p->dataBlockType_, p->selectedElevation_, requestedTime); | ||||||
| 
 | 
 | ||||||
|  |    std::unique_lock elevationCutsLock {p->elevationCutsMutex_}; | ||||||
|  |    p->elevationCuts_ = newElevationCuts; | ||||||
|  |    elevationCutsLock.unlock(); | ||||||
|  | 
 | ||||||
|    set_load_status(loadStatus); |    set_load_status(loadStatus); | ||||||
| 
 | 
 | ||||||
|    if (radarData == nullptr) |    if (radarData == nullptr) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat