diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2023-11-06 14:30:00 -0500 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2023-11-06 14:30:00 -0500 |
| commit | 9fd6264122f09752b4278c9ff881b4cfe906bbc8 (patch) | |
| tree | fd4c052b69f66144f73c2c33d7d2db9a68f68015 /include/framework | |
| parent | 56cc8f63a218bc13e0c8395b479267862de19714 (diff) | |
| download | dynamic-extension-9fd6264122f09752b4278c9ff881b4cfe906bbc8.tar.gz | |
DynamicExtension: fixed race in get_active_epoch_protected
This function wasn't ensuring that that the epoch pinned and the epoch
returned were the same epoch in the situation where the epoch was
advanced in the middle of the call. This is now resolved, and further the
function will return the newer epoch, rather than the older one, in
such a situation.
Diffstat (limited to 'include/framework')
| -rw-r--r-- | include/framework/DynamicExtension.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/framework/DynamicExtension.h b/include/framework/DynamicExtension.h index 60aa07e..233bebb 100644 --- a/include/framework/DynamicExtension.h +++ b/include/framework/DynamicExtension.h @@ -238,8 +238,17 @@ private: } _Epoch *get_active_epoch_protected() { - m_epochs[m_current_epoch.load()]->start_job(); - return m_epochs[m_current_epoch.load()]; + ssize_t cur_epoch = -1; + do { + if (cur_epoch != -1) { + m_epochs[cur_epoch]->end_job(); + } + + cur_epoch = m_current_epoch.load(); + m_epochs[cur_epoch]->start_job(); + } while (cur_epoch != m_current_epoch.load()); + + return m_epochs[cur_epoch]; } void advance_epoch() { |